/** @format */

(function(u, m) {
  var D = {},
    g = function(a, b) {
      var d, q, c;
      if ("string" === typeof a) return k(a);
      d = [];
      q = a.length;
      for (c = 0; c < q; c++) d.push(k(a[c]));
      return b.apply(null, d);
    },
    h = function(a, b, d) {
      2 === arguments.length && ((d = b), (b = null));
      g(b || [], function() {
        var b = arguments,
          e = { exports: d };
        "function" === typeof d &&
          (b.length || (b = [g, e.exports, e]),
          (b = d.apply(null, b)),
          void 0 !== b && (e.exports = b));
        D[a] = e.exports;
      });
    },
    k = function(a) {
      var b = D[a] || u[a];
      if (!b) throw Error("`" + a + "` is undefined");
      return b;
    },
    c = function(a) {
      var b, d, q, c, z, p;
      p = function(a) {
        return a && a.charAt(0).toUpperCase() + a.substr(1);
      };
      for (b in D)
        if (((d = a), D.hasOwnProperty(b))) {
          q = b.split("/");
          for (z = p(q.pop()); (c = p(q.shift())); )
            (d[c] = d[c] || {}), (d = d[c]);
          d[z] = D[b];
        }
      return a;
    },
    b = function(a) {
      u.__dollar = a;
      return c(m(u, h, g));
    },
    a;
  "object" === typeof module && "object" === typeof module.exports
    ? (module.exports = b())
    : "function" === typeof define && define.amd
    ? define(["jquery"], b)
    : ((a = u.WebUploader),
      (u.WebUploader = b()),
      (u.WebUploader.noConflict = function() {
        u.WebUploader = a;
      }));
})(window, function(u, m, D) {
  m("dollar-third", [], function() {
    var g = u.__dollar || u.jQuery || u.Zepto;
    if (!g) throw Error("jQuery or Zepto not found!");
    return g;
  });
  m("dollar", ["dollar-third"], function(g) {
    return g;
  });
  m("promise-third", ["dollar"], function(g) {
    return {
      Deferred: g.Deferred,
      when: g.when,
      isPromise: function(g) {
        return g && "function" === typeof g.then;
      }
    };
  });
  m("promise", ["promise-third"], function(g) {
    return g;
  });
  m("base", ["dollar", "promise"], function(g, h) {
    function k(a, b) {
      return function() {
        return a.apply(b, arguments);
      };
    }
    function c(a) {
      var b;
      if (Object.create) return Object.create(a);
      b = function() {};
      b.prototype = a;
      return new b();
    }
    var b = function() {},
      a = Function.call,
      f = h.Deferred,
      e = h.isPromise,
      d = h.when,
      q = (function(a) {
        var b = {},
          d = a.match(/WebKit\/([\d.]+)/),
          f = a.match(/Chrome\/([\d.]+)/) || a.match(/CriOS\/([\d.]+)/),
          q =
            a.match(/MSIE\s([\d\.]+)/) ||
            a.match(/(?:trident)(?:.*rv:([\w.]+))?/i),
          e = a.match(/Firefox\/([\d.]+)/),
          c = a.match(/Safari\/([\d.]+)/);
        a = a.match(/OPR\/([\d.]+)/);
        d && (b.webkit = parseFloat(d[1]));
        f && (b.chrome = parseFloat(f[1]));
        q && (b.ie = parseFloat(q[1]));
        e && (b.firefox = parseFloat(e[1]));
        c && (b.safari = parseFloat(c[1]));
        a && (b.opera = parseFloat(a[1]));
        return b;
      })(navigator.userAgent),
      r = (function(a) {
        var b = {},
          d = a.match(/(?:Android);?[\s\/]+([\d.]+)?/);
        a = a.match(/(?:iPad|iPod|iPhone).*OS\s([\d_]+)/);
        d && (b.android = parseFloat(d[1]));
        a && (b.ios = parseFloat(a[1].replace(/_/g, ".")));
        return b;
      })(navigator.userAgent),
      z;
    z = u.console ? k(console.log, console) : b;
    return {
      version: "0.1.5",
      $: g,
      Deferred: f,
      isPromise: e,
      when: d,
      browser: q,
      os: r,
      inherits: function(a, b, d) {
        var f;
        "function" === typeof b
          ? ((f = b), (b = null))
          : (f =
              b && b.hasOwnProperty("constructor")
                ? b.constructor
                : function() {
                    return a.apply(this, arguments);
                  });
        g.extend(!0, f, a, d || {});
        f.__super__ = a.prototype;
        f.prototype = c(a.prototype);
        b && g.extend(!0, f.prototype, b);
        return f;
      },
      noop: b,
      bindFn: k,
      log: z,
      nextTick: (function() {
        return function(a) {
          setTimeout(a, 1);
        };
      })(),
      slice: (function(b) {
        return function() {
          return a.apply(b, arguments);
        };
      })([].slice),
      guid: (function() {
        var a = 0;
        return function(b) {
          for (var d = (+new Date()).toString(32), f = 0; 5 > f; f++)
            d += Math.floor(65535 * Math.random()).toString(32);
          return (b || "wu_") + d + (a++).toString(32);
        };
      })(),
      formatSize: function(a, b, d) {
        var f;
        for (d = d || ["B", "K", "M", "G", "TB"]; (f = d.shift()) && 1024 < a; )
          a /= 1024;
        return ("B" === f ? a : a.toFixed(b || 2)) + f;
      }
    };
  });
  m("mediator", ["base"], function(g) {
    function h(a, f, e, c) {
      return b.grep(a, function(a) {
        return (
          a &&
          (!f || a.e === f) &&
          (!e || a.cb === e || a.cb._cb === e) &&
          (!c || a.ctx === c)
        );
      });
    }
    function k(a, q, e) {
      b.each((a || "").split(f), function(a, b) {
        e(b, q);
      });
    }
    function c(a, b) {
      for (var f = !1, e = -1, c = a.length, t; ++e < c; )
        if (((t = a[e]), !1 === t.cb.apply(t.ctx2, b))) {
          f = !0;
          break;
        }
      return !f;
    }
    var b = g.$,
      a = [].slice,
      f = /\s+/,
      e;
    e = {
      on: function(a, b, f) {
        var e = this,
          c;
        if (!b) return this;
        c = this._events || (this._events = []);
        k(a, b, function(a, b) {
          var d = { e: a };
          d.cb = b;
          d.ctx = f;
          d.ctx2 = f || e;
          d.id = c.length;
          c.push(d);
        });
        return this;
      },
      once: function(a, b, f) {
        var e = this;
        if (!b) return e;
        k(a, b, function(a, b) {
          var d = function() {
            e.off(a, d);
            return b.apply(f || e, arguments);
          };
          d._cb = b;
          e.on(a, d, f);
        });
        return e;
      },
      off: function(a, f, e) {
        var c = this._events;
        if (!c) return this;
        if (!a && !f && !e) return (this._events = []), this;
        k(a, f, function(a, d) {
          b.each(h(c, a, d, e), function() {
            delete c[this.id];
          });
        });
        return this;
      },
      trigger: function(b) {
        var f, e, g;
        if (!this._events || !b) return this;
        f = a.call(arguments, 1);
        e = h(this._events, b);
        g = h(this._events, "all");
        return c(e, f) && c(g, arguments);
      }
    };
    return b.extend(
      {
        installTo: function(a) {
          return b.extend(a, e);
        }
      },
      e
    );
  });
  m("uploader", ["base", "mediator"], function(g, h) {
    function k(b) {
      this.options = c.extend(!0, {}, k.options, b);
      this._init(this.options);
    }
    var c = g.$;
    k.options = {};
    h.installTo(k.prototype);
    c.each(
      {
        upload: "start-upload",
        stop: "stop-upload",
        getFile: "get-file",
        getFiles: "get-files",
        addFile: "add-file",
        addFiles: "add-file",
        sort: "sort-files",
        removeFile: "remove-file",
        cancelFile: "cancel-file",
        skipFile: "skip-file",
        retry: "retry",
        isInProgress: "is-in-progress",
        makeThumb: "make-thumb",
        md5File: "md5-file",
        getDimension: "get-dimension",
        addButton: "add-btn",
        predictRuntimeType: "predict-runtime-type",
        refresh: "refresh",
        disable: "disable",
        enable: "enable",
        reset: "reset"
      },
      function(b, a) {
        k.prototype[b] = function() {
          return this.request(a, arguments);
        };
      }
    );
    c.extend(k.prototype, {
      state: "pending",
      _init: function(b) {
        var a = this;
        a.request("init", b, function() {
          a.state = "ready";
          a.trigger("ready");
        });
        0 == b.extension.debug && (WebUploader.Base.log = function() {});
      },
      option: function(b, a) {
        var f = this.options;
        if (1 < arguments.length)
          c.isPlainObject(a) && c.isPlainObject(f[b])
            ? c.extend(f[b], a)
            : (f[b] = a);
        else return b ? f[b] : f;
      },
      getStats: function() {
        var b = this.request("get-stats");
        return b
          ? {
              successNum: b.numOfSuccess,
              progressNum: b.numOfProgress,
              cancelNum: b.numOfCancel,
              invalidNum: b.numOfInvalid,
              uploadFailNum: b.numOfUploadFailed,
              queueNum: b.numOfQueue,
              interruptNum: b.numofInterrupt
            }
          : {};
      },
      trigger: function(b) {
        var a = [].slice.call(arguments, 1),
          f = this.options,
          e = "on" + b.substring(0, 1).toUpperCase() + b.substring(1);
        return !1 === h.trigger.apply(this, arguments) ||
          (c.isFunction(f[e]) && !1 === f[e].apply(this, a)) ||
          (c.isFunction(this[e]) && !1 === this[e].apply(this, a)) ||
          !1 === h.trigger.apply(h, [this, b].concat(a))
          ? !1
          : !0;
      },
      destroy: function() {
        this.request("destroy", arguments);
        this.off();
      },
      request: g.noop
    });
    g.create = k.create = function(b) {
      return new k(b);
    };
    return (g.Uploader = k);
  });
  m("runtime/runtime", ["base", "mediator"], function(g, h) {
    function k(a) {
      this.options = c.extend({ container: document.body }, a);
      this.uid = g.guid("rt_");
    }
    var c = g.$,
      b = {},
      a = function(a) {
        for (var b in a) if (a.hasOwnProperty(b)) return b;
        return null;
      };
    c.extend(k.prototype, {
      getContainer: function() {
        var a, b;
        if (this._container) return this._container;
        a = c(this.options.container || document.body);
        b = c(document.createElement("div"));
        b.attr("id", "rt_" + this.uid);
        b.css({
          position: "absolute",
          top: "0px",
          left: "0px",
          width: "1px",
          height: "1px",
          overflow: "hidden"
        });
        a.append(b);
        a.addClass("webuploader-container");
        this._container = b;
        this._parent = a;
        return b;
      },
      init: g.noop,
      exec: g.noop,
      destroy: function() {
        this._container && this._container.remove();
        this._parent && this._parent.removeClass("webuploader-container");
        this.off();
      }
    });
    k.orders = "html5,flash";
    k.addRuntime = function(a, e) {
      b[a] = e;
    };
    k.hasRuntime = function(f) {
      return !(f ? !b[f] : !a(b));
    };
    k.create = function(f, e) {
      var d;
      e = e || k.orders;
      c.each(e.split(/\s*,\s*/g), function() {
        if (b[this]) return (d = this), !1;
      });
      d = d || a(b);
      if (!d) throw Error("Runtime Error");
      return new b[d](f);
    };
    h.installTo(k.prototype);
    return k;
  });
  m("runtime/client", ["base", "mediator", "runtime/runtime"], function(
    g,
    h,
    k
  ) {
    function c(a, f) {
      var e = g.Deferred(),
        d;
      this.uid = g.guid("client_");
      this.runtimeReady = function(a) {
        return e.done(a);
      };
      this.connectRuntime = function(a, c) {
        if (d) throw Error("already connected!");
        e.done(c);
        "string" === typeof a && b.get(a) && (d = b.get(a));
        (d = d || b.get(null, f))
          ? (g.$.extend(d.options, a),
            d.__promise.then(e.resolve),
            d.__client++)
          : ((d = k.create(a, a.runtimeOrder)),
            (d.__promise = e.promise()),
            d.once("ready", e.resolve),
            d.init(),
            b.add(d),
            (d.__client = 1));
        f && (d.__standalone = f);
        return d;
      };
      this.getRuntime = function() {
        return d;
      };
      this.disconnectRuntime = function() {
        d &&
          (d.__client--,
          0 >= d.__client && (b.remove(d), delete d.__promise, d.destroy()),
          (d = null));
      };
      this.exec = function() {
        if (d) {
          var b = g.slice(arguments);
          a && b.unshift(a);
          return d.exec.apply(this, b);
        }
      };
      this.getRuid = function() {
        return d && d.uid;
      };
      this.destroy = (function(a) {
        return function() {
          a && a.apply(this, arguments);
          this.trigger("destroy");
          this.off();
          this.exec("destroy");
          this.disconnectRuntime();
        };
      })(this.destroy);
    }
    var b;
    b = (function() {
      var a = {};
      return {
        add: function(b) {
          a[b.uid] = b;
        },
        get: function(b, e) {
          var d;
          if (b) return a[b];
          for (d in a) if (!e || !a[d].__standalone) return a[d];
          return null;
        },
        remove: function(b) {
          delete a[b.uid];
        }
      };
    })();
    h.installTo(c.prototype);
    return c;
  });
  m("lib/dnd", ["base", "mediator", "runtime/client"], function(g, h, k) {
    function c(a) {
      a = this.options = b.extend({}, c.options, a);
      a.container = b(a.container);
      a.container.length && k.call(this, "DragAndDrop");
    }
    var b = g.$;
    c.options = { accept: null, disableGlobalDnd: !1 };
    g.inherits(k, {
      constructor: c,
      init: function() {
        var a = this;
        a.connectRuntime(a.options, function() {
          a.exec("init");
          a.trigger("ready");
        });
      }
    });
    h.installTo(c.prototype);
    return c;
  });
  m("widgets/widget", ["base", "uploader"], function(g, h) {
    function k(a) {
      if (!a) return !1;
      var d = a.length,
        f = b.type(a);
      return 1 === a.nodeType && d
        ? !0
        : "array" === f ||
            ("function" !== f &&
              "string" !== f &&
              (0 === d || ("number" === typeof d && 0 < d && d - 1 in a)));
    }
    function c(a) {
      this.owner = a;
      this.options = a.options;
    }
    var b = g.$,
      a = h.prototype._init,
      f = h.prototype.destroy,
      e = {},
      d = [];
    b.extend(c.prototype, {
      init: g.noop,
      invoke: function(a, d) {
        var f = this.responseMap;
        return f && a in f && f[a] in this && b.isFunction(this[f[a]])
          ? this[f[a]].apply(this, d)
          : e;
      },
      request: function() {
        return this.owner.request.apply(this.owner, arguments);
      }
    });
    b.extend(h.prototype, {
      _init: function() {
        var f = this,
          e = (f._widgets = []),
          c = f.options.disableWidgets || "";
        b.each(d, function(a, b) {
          (c && ~c.indexOf(b._name)) || e.push(new b(f));
        });
        return a.apply(f, arguments);
      },
      request: function(a, b, d) {
        var f = 0,
          c = this._widgets,
          x = c && c.length,
          y = [],
          w = [],
          l;
        for (b = k(b) ? b : [b]; f < x; f++)
          (l = c[f]),
            (l = l.invoke(a, b)),
            l !== e && (g.isPromise(l) ? w.push(l) : y.push(l));
        return d || w.length
          ? ((a = g.when.apply(g, w)),
            (b = a.pipe ? "pipe" : "then"),
            a[b](function() {
              var a = g.Deferred(),
                b = arguments;
              1 === b.length && (b = b[0]);
              setTimeout(function() {
                a.resolve(b);
              }, 1);
              return a.promise();
            })[d ? b : "done"](d || g.noop))
          : y[0];
      },
      destroy: function() {
        f.apply(this, arguments);
        this._widgets = null;
      }
    });
    h.register = c.register = function(a, f) {
      var e = { init: "init", destroy: "destroy", name: "anonymous" },
        k;
      1 === arguments.length
        ? ((f = a),
          b.each(f, function(a) {
            "_" === a[0] || "name" === a
              ? "name" === a && (e.name = f.name)
              : (e[a.replace(/[A-Z]/g, "-$&").toLowerCase()] = a);
          }))
        : (e = b.extend(e, a));
      f.responseMap = e;
      k = g.inherits(c, f);
      k._name = e.name;
      d.push(k);
      return k;
    };
    h.unRegister = c.unRegister = function(a) {
      if (a && "anonymous" !== a)
        for (var b = d.length; b--; ) d[b]._name === a && d.splice(b, 1);
    };
    return c;
  });
  m(
    "widgets/filednd",
    ["base", "uploader", "lib/dnd", "widgets/widget"],
    function(g, h, k) {
      var c = g.$;
      h.options.dnd = "";
      return h.register({
        name: "dnd",
        init: function(b) {
          if (b.dnd && "html5" === this.request("predict-runtime-type")) {
            var a = this,
              f = g.Deferred();
            b = c.extend(
              {},
              {
                disableGlobalDnd: b.disableGlobalDnd,
                container: b.dnd,
                accept: b.accept
              }
            );
            this.dnd = b = new k(b);
            b.once("ready", f.resolve);
            b.on("drop", function(b) {
              a.request("add-file", [b]);
            });
            b.on("accept", function(b) {
              return a.owner.trigger("dndAccept", b);
            });
            b.init();
            return f.promise();
          }
        },
        destroy: function() {
          this.dnd && this.dnd.destroy();
        }
      });
    }
  );
  m("lib/filepaste", ["base", "mediator", "runtime/client"], function(g, h, k) {
    function c(a) {
      a = this.options = b.extend({}, a);
      a.container = b(a.container || document.body);
      k.call(this, "FilePaste");
    }
    var b = g.$;
    g.inherits(k, {
      constructor: c,
      init: function() {
        var a = this;
        a.connectRuntime(a.options, function() {
          a.exec("init");
          a.trigger("ready");
        });
      }
    });
    h.installTo(c.prototype);
    return c;
  });
  m(
    "widgets/filepaste",
    ["base", "uploader", "lib/filepaste", "widgets/widget"],
    function(g, h, k) {
      var c = g.$;
      return h.register({
        name: "paste",
        init: function(b) {
          if (b.paste && "html5" === this.request("predict-runtime-type")) {
            var a = this,
              f = g.Deferred();
            b = c.extend({}, { container: b.paste, accept: b.accept });
            this.paste = b = new k(b);
            b.once("ready", f.resolve);
            b.on("paste", function(b) {
              a.owner.request("add-file", [b]);
            });
            b.init();
            return f.promise();
          }
        },
        destroy: function() {
          this.paste && this.paste.destroy();
        }
      });
    }
  );
  m("lib/blob", ["base", "runtime/client"], function(g, h) {
    function k(c, b) {
      this.source = b;
      this.ruid = c;
      this.size = b.size || 0;
      !b.type && this.ext && ~"jpg,jpeg,png,gif,bmp".indexOf(this.ext)
        ? (this.type = "image/" + ("jpg" === this.ext ? "jpeg" : this.ext))
        : (this.type = b.type || "application/octet-stream");
      h.call(this, "Blob");
      this.uid = b.uid || this.uid;
      c && this.connectRuntime(c);
    }
    g.inherits(h, {
      constructor: k,
      slice: function(c, b) {
        return this.exec("slice", c, b);
      },
      getSource: function() {
        return this.source;
      }
    });
    return k;
  });
  m("lib/file", ["base", "lib/blob"], function(g, h) {
    function k(a, f) {
      var e;
      this.name = f.name || "untitled" + c++;
      e = b.exec(f.name) ? RegExp.$1.toLowerCase() : "";
      !e &&
        f.type &&
        ((e = /\/(jpg|jpeg|png|gif|bmp)$/i.exec(f.type)
          ? RegExp.$1.toLowerCase()
          : ""),
        (this.name += "." + e));
      this.ext = e;
      this.lastModifiedDate = f.lastModifiedDate || new Date().toLocaleString();
      h.apply(this, arguments);
    }
    var c = 1,
      b = /\.([^.]+)$/;
    return g.inherits(h, k);
  });
  m("lib/filepicker", ["base", "runtime/client", "lib/file"], function(
    g,
    h,
    k
  ) {
    function c(a) {
      a = this.options = b.extend({}, c.options, a);
      a.container = b(a.id);
      if (!a.container.length)
        throw Error("\u6309\u94ae\u6307\u5b9a\u9519\u8bef");
      a.innerHTML = a.innerHTML || a.label || a.container.html() || "";
      a.button = b(a.button || document.createElement("div"));
      a.button.html(a.innerHTML);
      a.container.html(a.button);
      h.call(this, "FilePicker", !0);
    }
    var b = g.$;
    c.options = {
      button: null,
      container: null,
      label: null,
      innerHTML: null,
      multiple: !0,
      accept: null,
      name: "file"
    };
    g.inherits(h, {
      constructor: c,
      init: function() {
        var a = this,
          f = a.options,
          e = f.button;
        e.addClass("webuploader-pick");
        a.on("all", function(d) {
          switch (d) {
            case "mouseenter":
              e.addClass("webuploader-pick-hover");
              break;
            case "mouseleave":
              e.removeClass("webuploader-pick-hover");
              break;
            case "change":
              (d = a.exec("getFiles")),
                a.trigger(
                  "select",
                  b.map(d, function(b) {
                    b = new k(a.getRuid(), b);
                    b._refer = f.container;
                    return b;
                  }),
                  f.container
                );
          }
        });
        a.connectRuntime(f, function() {
          a.refresh();
          a.exec("init", f);
          a.trigger("ready");
        });
        this._resizeHandler = g.bindFn(this.refresh, this);
        b(u).on("resize", this._resizeHandler);
      },
      refresh: function() {
        var a = this.getRuntime().getContainer(),
          b = this.options.button,
          e = b.outerWidth ? b.outerWidth() : b.width(),
          d = b.outerHeight ? b.outerHeight() : b.height(),
          b = b.offset();
        e &&
          d &&
          a
            .css({
              bottom: "auto",
              right: "auto",
              width: e + "px",
              height: d + "px"
            })
            .offset(b);
      },
      enable: function() {
        this.options.button.removeClass("webuploader-pick-disable");
        this.refresh();
      },
      disable: function() {
        var a = this.options.button;
        this.getRuntime()
          .getContainer()
          .css({ top: "-99999px" });
        a.addClass("webuploader-pick-disable");
      },
      destroy: function() {
        var a = this.options.button;
        b(u).off("resize", this._resizeHandler);
        a.removeClass(
          "webuploader-pick-disable webuploader-pick-hover webuploader-pick"
        );
      }
    });
    return c;
  });
  m(
    "widgets/filepicker",
    ["base", "uploader", "lib/filepicker", "widgets/widget"],
    function(g, h, k) {
      var c = g.$;
      c.extend(h.options, { pick: null, accept: null });
      return h.register({
        name: "picker",
        init: function(b) {
          this.pickers = [];
          return b.pick && this.addBtn(b.pick);
        },
        refresh: function() {
          c.each(this.pickers, function() {
            this.refresh();
          });
        },
        addBtn: function(b) {
          var a = this,
            f = a.options,
            e = f.accept,
            d = [];
          if (b)
            return (
              c.isPlainObject(b) || (b = { id: b }),
              c(b.id).each(function() {
                var q, r;
                r = g.Deferred();
                q = c.extend({}, b, {
                  accept: c.isPlainObject(e) ? [e] : e,
                  swf: f.swf,
                  runtimeOrder: f.runtimeOrder,
                  id: this
                });
                q = new k(q);
                q.once("ready", r.resolve);
                q.on("select", function(b) {
                  a.owner.request("add-file", [b]);
                });
                q.init();
                a.pickers.push(q);
                d.push(r.promise());
              }),
              g.when.apply(g, d)
            );
        },
        disable: function() {
          c.each(this.pickers, function() {
            this.disable();
          });
        },
        enable: function() {
          c.each(this.pickers, function() {
            this.enable();
          });
        },
        destroy: function() {
          c.each(this.pickers, function() {
            this.destroy();
          });
          this.pickers = null;
        }
      });
    }
  );
  m("lib/image", ["base", "runtime/client", "lib/blob"], function(g, h, k) {
    function c(a) {
      this.options = b.extend({}, c.options, a);
      h.call(this, "Image");
      this.on("load", function() {
        this._info = this.exec("info");
        this._meta = this.exec("meta");
      });
    }
    var b = g.$;
    c.options = {
      quality: 90,
      crop: !1,
      preserveHeaders: !1,
      allowMagnify: !1
    };
    g.inherits(h, {
      constructor: c,
      info: function(a) {
        return a ? ((this._info = a), this) : this._info;
      },
      meta: function(a) {
        return a ? ((this._meta = a), this) : this._meta;
      },
      loadFromBlob: function(a) {
        var b = this,
          e = a.getRuid();
        this.connectRuntime(e, function() {
          b.exec("init", b.options);
          b.exec("loadFromBlob", a);
        });
      },
      resize: function() {
        var a = g.slice(arguments);
        return this.exec.apply(this, ["resize"].concat(a));
      },
      crop: function() {
        var a = g.slice(arguments);
        return this.exec.apply(this, ["crop"].concat(a));
      },
      getAsDataUrl: function(a) {
        return this.exec("getAsDataUrl", a);
      },
      getAsBlob: function(a) {
        a = this.exec("getAsBlob", a);
        return new k(this.getRuid(), a);
      }
    });
    return c;
  });
  m(
    "widgets/image",
    ["base", "uploader", "lib/image", "widgets/widget"],
    function(g, h, k) {
      var c = g.$,
        b;
      b = (function(a) {
        var b = 0,
          e = [],
          d = function() {
            for (var d; e.length && b < a; )
              (d = e.shift()), (b += d[0]), d[1]();
          };
        return function(a, c, k) {
          e.push([c, k]);
          a.once("destroy", function() {
            b -= c;
            setTimeout(d, 1);
          });
          setTimeout(d, 1);
        };
      })(5242880);
      c.extend(h.options, {
        thumb: {
          width: 110,
          height: 110,
          quality: 70,
          allowMagnify: !0,
          crop: !0,
          preserveHeaders: !1,
          type: "image/jpeg"
        },
        compress: {
          width: 1600,
          height: 1600,
          quality: 90,
          allowMagnify: !1,
          crop: !1,
          preserveHeaders: !0
        }
      });
      return h.register({
        name: "image",
        makeThumb: function(a, f, e, d) {
          var q, r;
          a = this.request("get-file", a);
          a.type.match(/^image/)
            ? ((q = c.extend({}, this.options.thumb)),
              c.isPlainObject(e) && ((q = c.extend(q, e)), (e = null)),
              (e = e || q.width),
              (d = d || q.height),
              (r = new k(q)),
              r.once("load", function() {
                a._info = a._info || r.info();
                a._meta = a._meta || r.meta();
                1 >= e && 0 < e && (e *= a._info.width);
                1 >= d && 0 < d && (d *= a._info.height);
                r.resize(e, d);
              }),
              r.once("complete", function() {
                f(!1, r.getAsDataUrl(q.type));
                r.destroy();
              }),
              r.once("error", function(a) {
                f(a || !0);
                r.destroy();
              }),
              b(r, a.source.size, function() {
                a._info && r.info(a._info);
                a._meta && r.meta(a._meta);
                r.loadFromBlob(a.source);
              }))
            : f(!0);
        },
        beforeSendFile: function(a) {
          var b = this.options.compress || this.options.resize,
            e = (b && b.compressSize) || 0,
            d = (b && b.noCompressIfLarger) || !1,
            q,
            r;
          a = this.request("get-file", a);
          if (
            b &&
            ~"image/jpeg,image/jpg".indexOf(a.type) &&
            !(a.size < e) &&
            !a._compressed
          )
            return (
              (b = c.extend({}, b)),
              (r = g.Deferred()),
              (q = new k(b)),
              r.always(function() {
                q.destroy();
                q = null;
              }),
              q.once("error", r.reject),
              q.once("load", function() {
                var d = b.width,
                  e = b.height;
                a._info = a._info || q.info();
                a._meta = a._meta || q.meta();
                1 >= d && 0 < d && (d *= a._info.width);
                1 >= e && 0 < e && (e *= a._info.height);
                q.resize(d, e);
              }),
              q.once("complete", function() {
                var e, c;
                try {
                  e = q.getAsBlob(b.type);
                  c = a.size;
                  if (!d || e.size < c)
                    (a.source = e),
                      (a.size = e.size),
                      a.trigger("resize", e.size, c);
                  a._compressed = !0;
                  r.resolve();
                } catch (k) {
                  r.resolve();
                }
              }),
              a._info && q.info(a._info),
              a._meta && q.meta(a._meta),
              q.loadFromBlob(a.source),
              r.promise()
            );
        }
      });
    }
  );
  m("file", ["base", "mediator"], function(g, h) {
    function k(f) {
      this.name = f.name || "Untitled";
      this.size = f.size || 0;
      this.type = f.type || "application/octet-stream";
      this.lastModifiedDate = f.lastModifiedDate || 1 * new Date();
      this.id = "WU_FILE_" + c++;
      this.ext = b.exec(this.name) ? RegExp.$1 : "";
      this.statusText = "";
      a[this.id] = k.Status.INITED;
      this.source = f;
      this.loaded = 0;
      this.on("error", function(a) {
        this.setStatus(k.Status.ERROR, a);
      });
    }
    var c = 0,
      b = /\.([^.]+)$/,
      a = {};
    g.$.extend(k.prototype, {
      setStatus: function(b, e) {
        var d = a[this.id];
        "undefined" !== typeof e && (this.statusText = e);
        b !== d && ((a[this.id] = b), this.trigger("statuschange", b, d));
      },
      getStatus: function() {
        return a[this.id];
      },
      getSource: function() {
        return this.source;
      },
      destroy: function() {
        this.off();
        delete a[this.id];
      }
    });
    h.installTo(k.prototype);
    k.Status = {
      INITED: "inited",
      QUEUED: "queued",
      PROGRESS: "progress",
      ERROR: "error",
      COMPLETE: "complete",
      CANCELLED: "cancelled",
      INTERRUPT: "interrupt",
      INVALID: "invalid"
    };
    return k;
  });
  m("queue", ["base", "mediator", "file"], function(g, h, k) {
    function c() {
      this.stats = {
        numOfQueue: 0,
        numOfSuccess: 0,
        numOfCancel: 0,
        numOfProgress: 0,
        numOfUploadFailed: 0,
        numOfInvalid: 0,
        numofDeleted: 0,
        numofInterrupt: 0
      };
      this._queue = [];
      this._map = {};
    }
    var b = g.$,
      a = k.Status;
    b.extend(c.prototype, {
      append: function(a) {
        this._queue.push(a);
        this._fileAdded(a);
        return this;
      },
      prepend: function(a) {
        this._queue.unshift(a);
        this._fileAdded(a);
        return this;
      },
      getFile: function(a) {
        return "string" !== typeof a ? a : this._map[a];
      },
      fetch: function(b) {
        var e = this._queue.length,
          d,
          c;
        b = b || a.QUEUED;
        for (d = 0; d < e; d++)
          if (((c = this._queue[d]), b === c.getStatus())) return c;
        return null;
      },
      sort: function(a) {
        "function" === typeof a && this._queue.sort(a);
      },
      getFiles: function() {
        for (
          var a = [].slice.call(arguments, 0),
            e = [],
            d = 0,
            c = this._queue.length,
            r;
          d < c;
          d++
        )
          (r = this._queue[d]),
            (a.length && !~b.inArray(r.getStatus(), a)) || e.push(r);
        return e;
      },
      removeFile: function(a) {
        this._map[a.id] &&
          (delete this._map[a.id], a.destroy(), this.stats.numofDeleted++);
      },
      _fileAdded: function(a) {
        var b = this;
        this._map[a.id] ||
          ((this._map[a.id] = a),
          a.on("statuschange", function(a, c) {
            b._onFileStatusChange(a, c);
          }));
      },
      _onFileStatusChange: function(b, c) {
        var d = this.stats;
        switch (c) {
          case a.PROGRESS:
            d.numOfProgress--;
            break;
          case a.QUEUED:
            d.numOfQueue--;
            break;
          case a.ERROR:
            d.numOfUploadFailed--;
            break;
          case a.INVALID:
            d.numOfInvalid--;
            break;
          case a.INTERRUPT:
            d.numofInterrupt--;
        }
        switch (b) {
          case a.QUEUED:
            d.numOfQueue++;
            break;
          case a.PROGRESS:
            d.numOfProgress++;
            break;
          case a.ERROR:
            d.numOfUploadFailed++;
            break;
          case a.COMPLETE:
            d.numOfSuccess++;
            break;
          case a.CANCELLED:
            d.numOfCancel++;
            break;
          case a.INVALID:
            d.numOfInvalid++;
            break;
          case a.INTERRUPT:
            d.numofInterrupt++;
        }
      }
    });
    h.installTo(c.prototype);
    return c;
  });
  m(
    "widgets/queue",
    "base uploader queue file lib/file runtime/client widgets/widget".split(
      " "
    ),
    function(g, h, k, c, b, a) {
      var f = g.$,
        e = /\.\w+$/,
        d = c.Status;
      return h.register({
        name: "queue",
        init: function(b) {
          var d = this,
            c,
            e,
            t,
            x,
            y,
            w,
            l;
          f.isPlainObject(b.accept) && (b.accept = [b.accept]);
          if (b.accept) {
            y = [];
            t = 0;
            for (e = b.accept.length; t < e; t++)
              (x = b.accept[t].extensions) && y.push(x);
            y.length &&
              (w =
                "\\." +
                y
                  .join(",")
                  .replace(/,/g, "$|\\.")
                  .replace(/\*/g, ".*") +
                "$");
            d.accept = new RegExp(w, "i");
          }
          d.queue = new k();
          d.stats = d.queue.stats;
          if ("html5" === this.request("predict-runtime-type"))
            return (
              (c = g.Deferred()),
              (this.placeholder = l = new a("Placeholder")),
              l.connectRuntime({ runtimeOrder: "html5" }, function() {
                d._ruid = l.getRuid();
                c.resolve();
              }),
              c.promise()
            );
        },
        _wrapFile: function(a) {
          if (!(a instanceof c)) {
            if (!(a instanceof b)) {
              if (!this._ruid) throw Error("Can't add external files.");
              a = new b(this._ruid, a);
            }
            a = new c(a);
          }
          return a;
        },
        acceptFile: function(a) {
          return !(
            !a ||
            !a.size ||
            (this.accept && e.exec(a.name) && !this.accept.test(a.name))
          );
        },
        _addFile: function(a) {
          a = this._wrapFile(a);
          if (this.owner.trigger("beforeFileQueued", a)) {
            if (this.acceptFile(a))
              return (
                this.queue.append(a), this.owner.trigger("fileQueued", a), a
              );
            this.owner.trigger("error", "Q_TYPE_DENIED", a);
          }
        },
        getFile: function(a) {
          return this.queue.getFile(a);
        },
        addFile: function(a) {
          var b = this;
          a.length || (a = [a]);
          a = f.map(a, function(a) {
            return b._addFile(a);
          });
          b.owner.trigger("filesQueued", a);
          b.options.auto &&
            setTimeout(function() {
              b.request("start-upload");
            }, 20);
        },
        getStats: function() {
          return this.stats;
        },
        removeFile: function(a, b) {
          a = a.id ? a : this.queue.getFile(a);
          this.request("cancel-file", a);
          b && this.queue.removeFile(a);
        },
        getFiles: function() {
          return this.queue.getFiles.apply(this.queue, arguments);
        },
        fetchFile: function() {
          return this.queue.fetch.apply(this.queue, arguments);
        },
        retry: function(a, b) {
          var c, e, f;
          if (a)
            (a = a.id ? a : this.queue.getFile(a)),
              a.setStatus(d.QUEUED),
              b || this.request("start-upload");
          else {
            c = this.queue.getFiles(d.ERROR);
            e = 0;
            for (f = c.length; e < f; e++) (a = c[e]), a.setStatus(d.QUEUED);
            this.request("start-upload");
          }
        },
        sortFiles: function() {
          return this.queue.sort.apply(this.queue, arguments);
        },
        reset: function() {
          this.owner.trigger("reset");
          this.queue = new k();
          this.stats = this.queue.stats;
        },
        destroy: function() {
          this.reset();
          this.placeholder && this.placeholder.destroy();
        }
      });
    }
  );
  m(
    "widgets/runtime",
    ["uploader", "runtime/runtime", "widgets/widget"],
    function(g, h) {
      g.support = function() {
        return h.hasRuntime.apply(h, arguments);
      };
      return g.register({
        name: "runtime",
        init: function() {
          if (!this.predictRuntimeType()) throw Error("Runtime Error");
        },
        predictRuntimeType: function() {
          var k = this.options.runtimeOrder || h.orders,
            c = this.type,
            b,
            a;
          if (!c)
            for (k = k.split(/\s*,\s*/g), b = 0, a = k.length; b < a; b++)
              if (h.hasRuntime(k[b])) {
                this.type = c = k[b];
                break;
              }
          return c;
        }
      });
    }
  );
  m("lib/transport", ["base", "runtime/client", "mediator"], function(g, h, k) {
    function c(a) {
      var f = this;
      a = f.options = b.extend(!0, {}, c.options, a || {});
      h.call(this, "Transport");
      this._blob = null;
      this._formData = a.formData || {};
      this._headers = a.headers || {};
      this.on("progress", this._timeout);
      this.on("load error", function() {
        f.trigger("progress", 1);
        clearTimeout(f._timer);
      });
    }
    var b = g.$;
    c.options = {
      server: "",
      method: "POST",
      withCredentials: !1,
      fileVal: "file",
      timeout: 12e4,
      formData: {},
      headers: {},
      sendAsBinary: !1
    };
    b.extend(c.prototype, {
      appendBlob: function(a, b, c) {
        var d = this,
          q = d.options;
        d.getRuid() && d.disconnectRuntime();
        d.connectRuntime(b.ruid, function() {
          d.exec("init");
        });
        d._blob = b;
        q.fileVal = a || q.fileVal;
        q.filename = c || q.filename;
      },
      append: function(a, c) {
        "object" === typeof a
          ? b.extend(this._formData, a)
          : (this._formData[a] = c);
      },
      setRequestHeader: function(a, c) {
        "object" === typeof a
          ? b.extend(this._headers, a)
          : (this._headers[a] = c);
      },
      send: function(a) {
        this.exec("send", a);
        this._timeout();
      },
      abort: function() {
        clearTimeout(this._timer);
        return this.exec("abort");
      },
      destroy: function() {
        this.trigger("destroy");
        this.off();
        this.exec("destroy");
        this.disconnectRuntime();
      },
      getResponse: function() {
        return this.exec("getResponse");
      },
      getResponseAsJson: function() {
        return this.exec("getResponseAsJson");
      },
      getStatus: function() {
        return this.exec("getStatus");
      },
      _timeout: function() {
        var a = this,
          b = a.options.timeout;
        b &&
          (clearTimeout(a._timer),
          (a._timer = setTimeout(function() {
            a.abort();
            a.trigger("error", "timeout");
          }, b)));
      }
    });
    k.installTo(c.prototype);
    return c;
  });
  m(
    "widgets/upload",
    ["base", "uploader", "file", "lib/transport", "widgets/widget"],
    function(g, h, k, c) {
      function b(a, b) {
        var c = [],
          e = a.source.size,
          f = b ? Math.ceil(e / b) : 1,
          k = 0,
          x = 0,
          y,
          g;
        for (
          g = {
            file: a,
            has: function() {
              return !!c.length;
            },
            shift: function() {
              return c.shift();
            },
            unshift: function(a) {
              c.unshift(a);
            }
          };
          x < f;

        )
          (y = Math.min(b, e - k)),
            c.push({
              file: a,
              start: k,
              end: b ? k + y : e,
              total: e,
              chunks: f,
              chunk: x++,
              cuted: g
            }),
            (k += y);
        a.blocks = c.concat();
        a.remaning = c.length;
        return g;
      }
      var a = g.$,
        f = g.isPromise,
        e = k.Status;
      a.extend(h.options, {
        prepareNextFile: !1,
        chunked: !1,
        chunkSize: 5242880,
        chunkRetry: 2,
        threads: 3,
        formData: {},
        extension: { debug: !0 }
      });
      h.register({
        name: "upload",
        init: function() {
          var b = this.owner,
            c = this;
          this.progress = this.runing = !1;
          b.on("startUpload", function() {
            c.progress = !0;
          })
            .on("uploadFinished", function() {
              c.progress = !1;
            })
            .on("uploadBeforeSend", function(a, b) {
              b.appKey = this.options.extension.appName;
              b.filePath = a.file.uploadToken.filePath;
              b.token = a.file.uploadToken.token;
              b.expires = a.file.uploadToken.expires;
              delete b.chunks;
              delete b.lastModifiedDate;
              delete b.id;
              delete b.name;
              delete b.type;
              delete b.size;
            });
          this.pool = [];
          this.stack = [];
          this.pending = [];
          this.remaning = 0;
          this.__tick = g.bindFn(this._tick, this);
          b.on("uploadComplete", function(b) {
            b.blocks &&
              a.each(b.blocks, function(a, b) {
                b.transport && (b.transport.abort(), b.transport.destroy());
                delete b.transport;
              });
            delete b.blocks;
            delete b.remaning;
          });
        },
        reset: function() {
          this.request("stop-upload", !0);
          this.runing = !1;
          this.pool = [];
          this.stack = [];
          this.pending = [];
          this.remaning = 0;
          this._trigged = !1;
          this._promise = null;
        },
        startUpload: function(b) {
          var c = this;
          a.each(c.request("get-files", e.INVALID), function() {
            c.request("remove-file", this);
          });
          if (b) {
            b = b.id ? b : c.request("get-file", b);
            if (b.getStatus() === e.INTERRUPT)
              a.each(c.pool, function(a, c) {
                c.file === b && c.transport && c.transport.send();
              });
            else if (b.getStatus() === e.PROGRESS) return;
            b.setStatus(e.QUEUED);
          } else
            a.each(c.request("get-files", [e.INITED]), function() {
              this.setStatus(e.QUEUED);
            });
          if (!c.runing) {
            c.runing = !0;
            var f = [];
            for (
              a.each(c.pool, function(a, b) {
                var d = b.file;
                d.getStatus() === e.INTERRUPT &&
                  (f.push(d),
                  (c._trigged = !1),
                  b.transport && b.transport.send());
              });
              (b = f.shift());

            )
              b.setStatus(e.PROGRESS);
            b ||
              a.each(c.request("get-files", e.INTERRUPT), function() {
                this.setStatus(e.PROGRESS);
              });
            c._trigged = !1;
            g.nextTick(c.__tick);
            c.owner.trigger("startUpload");
          }
        },
        stopUpload: function(b, c) {
          var f = this;
          !0 === b && ((c = b), (b = null));
          if (!1 !== f.runing) {
            if (b) {
              b = b.id ? b : f.request("get-file", b);
              if (b.getStatus() !== e.PROGRESS && b.getStatus() !== e.QUEUED)
                return;
              b.setStatus(e.INTERRUPT);
              a.each(f.pool, function(a, c) {
                c.file === b &&
                  (c.transport && c.transport.abort(),
                  f._putback(c),
                  f._popBlock(c));
              });
              return g.nextTick(f.__tick);
            }
            f.runing = !1;
            this._promise &&
              this._promise.file &&
              this._promise.file.setStatus(e.INTERRUPT);
            c &&
              a.each(f.pool, function(a, b) {
                b.transport && b.transport.abort();
                b.file.setStatus(e.INTERRUPT);
              });
            f.owner.trigger("stopUpload");
          }
        },
        cancelFile: function(b) {
          b = b.id ? b : this.request("get-file", b);
          b.blocks &&
            a.each(b.blocks, function(a, b) {
              var d = b.transport;
              d && (d.abort(), d.destroy(), delete b.transport);
            });
          b.setStatus(e.CANCELLED);
          this.owner.trigger("fileDequeued", b);
        },
        isInProgress: function() {
          return !!this.progress;
        },
        _getStats: function() {
          return this.request("get-stats");
        },
        skipFile: function(b, c) {
          b = b.id ? b : this.request("get-file", b);
          b.setStatus(c || e.COMPLETE);
          b.skipped = !0;
          b.blocks &&
            a.each(b.blocks, function(a, b) {
              var d = b.transport;
              d && (d.abort(), d.destroy(), delete b.transport);
            });
          this.owner.trigger("uploadSkip", b);
        },
        _tick: function() {
          var a = this,
            b = a.options,
            c;
          if (a._promise) return a._promise.always(a.__tick);
          a.pool.length < b.threads && (c = a._nextBlock())
            ? ((a._trigged = !1),
              (b = function(b) {
                a._promise = null;
                b && b.file && a._startSend(b);
                g.nextTick(a.__tick);
              }),
              (a._promise = f(c) ? c.always(b) : b(c)))
            : a.remaning ||
              a._getStats().numOfQueue ||
              a._getStats().numofInterrupt ||
              ((a.runing = !1),
              a._trigged ||
                g.nextTick(function() {
                  a.owner.trigger("uploadFinished");
                }),
              (a._trigged = !0));
        },
        _putback: function(a) {
          a.cuted.unshift(a);
          ~this.stack.indexOf(a.cuted) || this.stack.unshift(a.cuted);
        },
        _getStack: function() {
          for (var a = 0, b; (b = this.stack[a++]); ) {
            if (b.has() && b.file.getStatus() === e.PROGRESS) return b;
            (!b.has() ||
              (b.file.getStatus() !== e.PROGRESS &&
                b.file.getStatus() !== e.INTERRUPT)) &&
              this.stack.splice(--a, 1);
          }
          return null;
        },
        _nextBlock: function() {
          var a = this,
            c = a.options,
            e,
            k,
            g,
            t;
          if ((e = this._getStack()))
            return (
              c.prepareNextFile && !a.pending.length && a._prepareNextFile(),
              e.shift()
            );
          if (a.runing)
            return (
              !a.pending.length &&
                a._getStats().numOfQueue &&
                a._prepareNextFile(),
              (k = a.pending.shift()),
              (g = function(f) {
                if (!f) return null;
                e = b(f, c.chunked ? c.chunkSize : 0);
                a.stack.push(e);
                return e.shift();
              }),
              f(k)
                ? ((t = k.file),
                  (k = k[k.pipe ? "pipe" : "then"](g)),
                  (k.file = t),
                  k)
                : g(k)
            );
        },
        _prepareNextFile: function() {
          var b = this,
            c = b.request("fetch-file"),
            f = b.pending,
            k;
          c &&
            ((k = b.request("before-send-file", c, function() {
              return c.getStatus() === e.PROGRESS ||
                c.getStatus() === e.INTERRUPT
                ? c
                : b._finishFile(c);
            })),
            b.owner.trigger("uploadStart", c),
            c.setStatus(e.PROGRESS),
            (k.file = c),
            k.done(function() {
              var b = a.inArray(k, f);
              ~b && f.splice(b, 1, c);
            }),
            k.fail(function(a) {
              c.setStatus(e.ERROR, a);
              b.owner.trigger("uploadError", c, a);
              b.owner.trigger("uploadComplete", c);
            }),
            f.push(k));
        },
        _popBlock: function(b) {
          var c = a.inArray(b, this.pool);
          this.pool.splice(c, 1);
          b.file.remaning--;
          this.remaning--;
        },
        _startSend: function(a) {
          var b = this,
            c = a.file,
            f;
          c.getStatus() !== e.PROGRESS
            ? c.getStatus() === e.INTERRUPT && b._putback(a)
            : (b.pool.push(a),
              b.remaning++,
              (a.blob =
                1 === a.chunks ? c.source : c.source.slice(a.start, a.end)),
              (f = b.request("before-send", a, function() {
                c.getStatus() === e.PROGRESS
                  ? b._doSend(a)
                  : (b._popBlock(a), g.nextTick(b.__tick));
              })),
              f.fail(function() {
                1 === c.remaning
                  ? b._finishFile(c).always(function() {
                      a.percentage = 1;
                      b._popBlock(a);
                      b.owner.trigger("uploadComplete", c);
                      g.nextTick(b.__tick);
                    })
                  : ((a.percentage = 1),
                    b.updateFileProgress(c),
                    b._popBlock(a),
                    g.nextTick(b.__tick));
              }));
        },
        _doSend: function(b) {
          var f = this,
            k = f.owner,
            h = f.options,
            p = b.file,
            t = new c(h),
            x = a.extend({}, h.formData),
            y = a.extend({}, h.headers),
            w,
            l;
          b.transport = t;
          t.on("destroy", function() {
            delete b.transport;
            f._popBlock(b);
            g.nextTick(f.__tick);
          });
          t.on("progress", function(a) {
            b.percentage = a;
            f.updateFileProgress(p);
          });
          w = function(a) {
            l = t.getResponseAsJson() || {};
            l._raw = t.getResponse();
            k.trigger("uploadAccept", b, l, function(b) {
              a = b;
            }) || (a = a || "server");
            return a;
          };
          t.on("error", function(a, c) {
            b.retried = b.retried || 0;
            1 < b.chunks && ~"http,abort".indexOf(a) && b.retried < h.chunkRetry
              ? (b.retried++, t.send())
              : (c || "server" !== a || (a = w(a)),
                p.setStatus(e.ERROR, a),
                k.trigger("uploadError", p, a),
                k.trigger("uploadComplete", p));
          });
          t.on("load", function() {
            var a;
            (a = w())
              ? t.trigger("error", a, !0)
              : 1 === p.remaning
              ? f._finishFile(p, l)
              : t.destroy();
          });
          x = a.extend(x, {
            id: p.id,
            name: p.name,
            type: p.type,
            lastModifiedDate: p.lastModifiedDate,
            size: p.size
          });
          1 < b.chunks && a.extend(x, { chunks: b.chunks, chunk: b.chunk });
          k.trigger("uploadBeforeSend", b, x, y);
          t.appendBlob(h.fileVal, b.blob, p.name);
          t.append(x);
          t.setRequestHeader(y);
          t.send();
        },
        _finishFile: function(a, b, c) {
          var f = this.owner;
          return f
            .request("after-send-file", arguments, function() {
              a.setStatus(e.COMPLETE);
              f.trigger("uploadSuccess", a, b, c);
            })
            .fail(function(b) {
              a.getStatus() === e.PROGRESS && a.setStatus(e.ERROR, b);
              f.trigger("uploadError", a, b);
            })
            .always(function() {
              f.trigger("uploadComplete", a);
            });
        },
        updateFileProgress: function(b) {
          var c = 0,
            f = 0;
          b.blocks &&
            (a.each(b.blocks, function(a, b) {
              f += (b.percentage || 0) * (b.end - b.start);
            }),
            (c = f / b.size),
            this.owner.trigger("uploadProgress", b, c || 0));
        }
      });
    }
  );
  m(
    "widgets/validator",
    ["base", "uploader", "file", "widgets/widget"],
    function(g, h, k) {
      var c = g.$,
        b = {},
        a;
      a = {
        addValidator: function(a, c) {
          b[a] = c;
        },
        removeValidator: function(a) {
          delete b[a];
        }
      };
      h.register({
        name: "validator",
        init: function() {
          var a = this;
          g.nextTick(function() {
            c.each(b, function() {
              this.call(a.owner);
            });
          });
        }
      });
      a.addValidator("fileNumLimit", function() {
        var a = 0,
          b = parseInt(this.options.fileNumLimit, 10),
          c = !0;
        b &&
          (this.on("beforeFileQueued", function(k) {
            a >= b &&
              c &&
              ((c = !1),
              this.trigger("error", "Q_EXCEED_NUM_LIMIT", b, k),
              setTimeout(function() {
                c = !0;
              }, 1));
            return a >= b ? !1 : !0;
          }),
          this.on("fileQueued", function() {
            a++;
          }),
          this.on("fileDequeued", function() {
            a--;
          }),
          this.on("reset", function() {
            a = 0;
          }));
      });
      a.addValidator("fileSizeLimit", function() {
        var a = 0,
          b = parseInt(this.options.fileSizeLimit, 10),
          c = !0;
        b &&
          (this.on("beforeFileQueued", function(k) {
            var g = a + k.size > b;
            g &&
              c &&
              ((c = !1),
              this.trigger("error", "Q_EXCEED_SIZE_LIMIT", b, k),
              setTimeout(function() {
                c = !0;
              }, 1));
            return g ? !1 : !0;
          }),
          this.on("fileQueued", function(b) {
            a += b.size;
          }),
          this.on("fileDequeued", function(b) {
            a -= b.size;
          }),
          this.on("reset", function() {
            a = 0;
          }));
      });
      a.addValidator("fileSingleSizeLimit", function() {
        var a = this.options.fileSingleSizeLimit;
        if (a)
          this.on("beforeFileQueued", function(b) {
            if (b.size > a)
              return (
                b.setStatus(k.Status.INVALID, "exceed_size"),
                this.trigger("error", "F_EXCEED_SIZE", a, b),
                !1
              );
          });
      });
      a.addValidator("duplicate", function() {
        var a = {};
        this.options.duplicate ||
          (this.on("beforeFileQueued", function(b) {
            var c;
            if (!(c = b.__hash)) {
              c = b.name + b.size + b.lastModifiedDate;
              for (var k = 0, g = 0, h = c.length, p; g < h; g++)
                (p = c.charCodeAt(g)), (k = p + (k << 6) + (k << 16) - k);
              c = b.__hash = k;
            }
            if (a[c])
              return (
                this.trigger(
                  "error",
                  "\u6587\u4ef6\u5df2\u5b58\u5728\u4e8e\u5217\u8868\u4e2d",
                  b
                ),
                !1
              );
          }),
          this.on("fileQueued", function(b) {
            (b = b.__hash) && (a[b] = !0);
          }),
          this.on("fileDequeued", function(b) {
            (b = b.__hash) && delete a[b];
          }),
          this.on("reset", function() {
            a = {};
          }));
      });
      return a;
    }
  );
  m("lib/md5", ["runtime/client", "mediator"], function(g, h) {
    function k() {
      g.call(this, "Md5");
    }
    h.installTo(k.prototype);
    k.prototype.loadFromBlob = function(c) {
      var b = this;
      b.getRuid() && b.disconnectRuntime();
      b.connectRuntime(c.ruid, function() {
        b.exec("init");
        b.exec("loadFromBlob", c);
      });
    };
    k.prototype.getResult = function() {
      return this.exec("getResult");
    };
    return k;
  });
  m(
    "widgets/md5",
    ["base", "uploader", "lib/md5", "lib/blob", "widgets/widget"],
    function(g, h, k, c) {
      return h.register({
        name: "md5",
        md5File: function(b, a, f) {
          var e = new k(),
            d = g.Deferred(),
            h = b instanceof c ? b : this.request("get-file", b).source;
          e.on("progress load", function(a) {
            a = a || {};
            d.notify(a.total ? a.loaded / a.total : 1);
          });
          e.on("complete", function() {
            d.resolve(e.getResult());
          });
          e.on("error", function(a) {
            d.reject(a);
          });
          1 < arguments.length &&
            ((a = a || 0),
            (f = f || 0),
            0 > a && (a = h.size + a),
            0 > f && (f = h.size + f),
            (f = Math.min(f, h.size)),
            (h = h.slice(a, f)));
          e.loadFromBlob(h);
          return d.promise();
        }
      });
    }
  );
  m("runtime/compbase", [], function() {
    return function(g, h) {
      this.owner = g;
      this.options = g.options;
      this.getRuntime = function() {
        return h;
      };
      this.getRuid = function() {
        return h.uid;
      };
      this.trigger = function() {
        return g.trigger.apply(g, arguments);
      };
    };
  });
  m(
    "runtime/html5/runtime",
    ["base", "runtime/runtime", "runtime/compbase"],
    function(g, h, k) {
      function c() {
        var a = {},
          c = this,
          e = this.destroy;
        h.apply(c, arguments);
        c.type = "html5";
        c.exec = function(e, k) {
          var h = this.uid,
            m = g.slice(arguments, 2);
          if (b[e] && ((h = a[h] = a[h] || new b[e](this, c)), h[k]))
            return h[k].apply(h, m);
        };
        c.destroy = function() {
          return e && e.apply(this, arguments);
        };
      }
      var b = {};
      g.inherits(h, {
        constructor: c,
        init: function() {
          var a = this;
          setTimeout(function() {
            a.trigger("ready");
          }, 1);
        }
      });
      c.register = function(a, c) {
        return (b[a] = g.inherits(k, c));
      };
      u.Blob && u.FileReader && u.DataView && h.addRuntime("html5", c);
      return c;
    }
  );
  m("runtime/html5/blob", ["runtime/html5/runtime", "lib/blob"], function(
    g,
    h
  ) {
    return g.register("Blob", {
      slice: function(k, c) {
        var b = this.owner.source,
          b = (b.slice || b.webkitSlice || b.mozSlice).call(b, k, c);
        return new h(this.getRuid(), b);
      }
    });
  });
  m(
    "runtime/html5/dnd",
    ["base", "runtime/html5/runtime", "lib/file"],
    function(g, h, k) {
      var c = g.$;
      return h.register("DragAndDrop", {
        init: function() {
          var b = (this.elem = this.options.container);
          this.dragEnterHandler = g.bindFn(this._dragEnterHandler, this);
          this.dragOverHandler = g.bindFn(this._dragOverHandler, this);
          this.dragLeaveHandler = g.bindFn(this._dragLeaveHandler, this);
          this.dropHandler = g.bindFn(this._dropHandler, this);
          this.dndOver = !1;
          b.on("dragenter", this.dragEnterHandler);
          b.on("dragover", this.dragOverHandler);
          b.on("dragleave", this.dragLeaveHandler);
          b.on("drop", this.dropHandler);
          this.options.disableGlobalDnd &&
            (c(document).on("dragover", this.dragOverHandler),
            c(document).on("drop", this.dropHandler));
        },
        _dragEnterHandler: function(b) {
          var a = this._denied || !1,
            c;
          b = b.originalEvent || b;
          this.dndOver ||
            ((this.dndOver = !0),
            (c = b.dataTransfer.items) &&
              c.length &&
              (this._denied = a = !this.trigger("accept", c)),
            this.elem.addClass("webuploader-dnd-over"),
            this.elem[a ? "addClass" : "removeClass"](
              "webuploader-dnd-denied"
            ));
          b.dataTransfer.dropEffect = a ? "none" : "copy";
          return !1;
        },
        _dragOverHandler: function(b) {
          var a = this.elem.parent().get(0);
          if (a && !c.contains(a, b.currentTarget)) return !1;
          clearTimeout(this._leaveTimer);
          this._dragEnterHandler.call(this, b);
          return !1;
        },
        _dragLeaveHandler: function() {
          var b = this;
          clearTimeout(b._leaveTimer);
          b._leaveTimer = setTimeout(function() {
            b.dndOver = !1;
            b.elem.removeClass("webuploader-dnd-over webuploader-dnd-denied");
          }, 100);
          return !1;
        },
        _dropHandler: function(b) {
          var a = this,
            f = a.getRuid(),
            e = a.elem.parent().get(0),
            d;
          if (e && !c.contains(e, b.currentTarget)) return !1;
          b = b.originalEvent || b;
          b = b.dataTransfer;
          try {
            d = b.getData("text/html");
          } catch (g) {}
          a.dndOver = !1;
          a.elem.removeClass("webuploader-dnd-over");
          if (!d)
            return (
              a._getTansferFiles(b, function(b) {
                a.trigger(
                  "drop",
                  c.map(b, function(a) {
                    return new k(f, a);
                  })
                );
              }),
              !1
            );
        },
        _getTansferFiles: function(b, a) {
          var c = [],
            e = [],
            d,
            k,
            h,
            m,
            p,
            t,
            x;
          d = b.items;
          k = b.files;
          x = !(!d || !d[0].webkitGetAsEntry);
          p = 0;
          for (t = k.length; p < t; p++)
            (h = k[p]),
              (m = d && d[p]),
              x && m.webkitGetAsEntry().isDirectory
                ? e.push(this._traverseDirectoryTree(m.webkitGetAsEntry(), c))
                : c.push(h);
          g.when.apply(g, e).done(function() {
            c.length && a(c);
          });
        },
        _traverseDirectoryTree: function(b, a) {
          var c = g.Deferred(),
            e = this;
          b.isFile
            ? b.file(function(b) {
                a.push(b);
                c.resolve();
              })
            : b.isDirectory &&
              b.createReader().readEntries(function(b) {
                var k = b.length,
                  h = [],
                  m = [],
                  p;
                for (p = 0; p < k; p++)
                  h.push(e._traverseDirectoryTree(b[p], m));
                g.when.apply(g, h).then(function() {
                  a.push.apply(a, m);
                  c.resolve();
                }, c.reject);
              });
          return c.promise();
        },
        destroy: function() {
          var b = this.elem;
          b &&
            (b.off("dragenter", this.dragEnterHandler),
            b.off("dragover", this.dragOverHandler),
            b.off("dragleave", this.dragLeaveHandler),
            b.off("drop", this.dropHandler),
            this.options.disableGlobalDnd &&
              (c(document).off("dragover", this.dragOverHandler),
              c(document).off("drop", this.dropHandler)));
        }
      });
    }
  );
  m(
    "runtime/html5/filepaste",
    ["base", "runtime/html5/runtime", "lib/file"],
    function(g, h, k) {
      return h.register("FilePaste", {
        init: function() {
          var c = this.options,
            b = (this.elem = c.container),
            a = ".*",
            f,
            e,
            d,
            k;
          if (c.accept) {
            f = [];
            e = 0;
            for (d = c.accept.length; e < d; e++)
              (k = c.accept[e].mimeTypes) && f.push(k);
            f.length &&
              ((a = f.join(",")),
              (a = a.replace(/,/g, "|").replace(/\*/g, ".*")));
          }
          this.accept = new RegExp(a, "i");
          this.hander = g.bindFn(this._pasteHander, this);
          b.on("paste", this.hander);
        },
        _pasteHander: function(c) {
          var b = [],
            a = this.getRuid(),
            f,
            e,
            d,
            g,
            h;
          c = c.originalEvent || c;
          f = c.clipboardData.items;
          g = 0;
          for (h = f.length; g < h; g++)
            (e = f[g]),
              "file" === e.kind && (d = e.getAsFile()) && b.push(new k(a, d));
          b.length &&
            (c.preventDefault(), c.stopPropagation(), this.trigger("paste", b));
        },
        destroy: function() {
          this.elem.off("paste", this.hander);
        }
      });
    }
  );
  m("runtime/html5/filepicker", ["base", "runtime/html5/runtime"], function(
    g,
    h
  ) {
    var k = g.$;
    return h.register("FilePicker", {
      init: function() {
        var c = this.getRuntime().getContainer(),
          b = this,
          a = b.owner,
          f = b.options,
          e = (this.label = k(document.createElement("label"))),
          d = (this.input = k(document.createElement("input"))),
          g,
          h,
          m,
          p;
        d.attr("type", "file");
        d.attr("name", f.name);
        d.addClass("webuploader-element-invisible");
        e.on("click", function() {
          d.trigger("click");
        });
        e.css({
          opacity: 0,
          width: "100%",
          height: "100%",
          display: "block",
          cursor: "pointer",
          background: "#ffffff"
        });
        f.multiple && d.attr("multiple", "multiple");
        if (f.accept && 0 < f.accept.length) {
          g = [];
          h = 0;
          for (m = f.accept.length; h < m; h++) g.push(f.accept[h].mimeTypes);
          d.attr("accept", g.join(","));
        }
        c.append(d);
        c.append(e);
        p = function(b) {
          a.trigger(b.type);
        };
        d.on("change", function(c) {
          var e = arguments.callee,
            f;
          b.files = c.target.files;
          f = this.cloneNode(!0);
          f.value = null;
          this.parentNode.replaceChild(f, this);
          d.off();
          d = k(f)
            .on("change", e)
            .on("mouseenter mouseleave", p);
          a.trigger("change");
        });
        e.on("mouseenter mouseleave", p);
      },
      getFiles: function() {
        return this.files;
      },
      destroy: function() {
        this.input.off();
        this.label.off();
      }
    });
  });
  m("runtime/html5/util", ["base"], function(g) {
    var h =
        (u.createObjectURL && u) ||
        (u.URL && URL.revokeObjectURL && URL) ||
        u.webkitURL,
      k = (g = g.noop);
    h &&
      ((g = function() {
        return h.createObjectURL.apply(h, arguments);
      }),
      (k = function() {
        return h.revokeObjectURL.apply(h, arguments);
      }));
    return {
      createObjectURL: g,
      revokeObjectURL: k,
      dataURL2Blob: function(c) {
        var b, a, f, e;
        e = c.split(",");
        b = ~e[0].indexOf("base64") ? atob(e[1]) : decodeURIComponent(e[1]);
        c = new ArrayBuffer(b.length);
        a = new Uint8Array(c);
        for (f = 0; f < b.length; f++) a[f] = b.charCodeAt(f);
        b = e[0].split(":")[1].split(";")[0];
        return this.arrayBufferToBlob(c, b);
      },
      dataURL2ArrayBuffer: function(c) {
        var b, a;
        c = c.split(",");
        c = ~c[0].indexOf("base64") ? atob(c[1]) : decodeURIComponent(c[1]);
        b = new Uint8Array(c.length);
        for (a = 0; a < c.length; a++) b[a] = c.charCodeAt(a);
        return b.buffer;
      },
      arrayBufferToBlob: function(c, b) {
        var a = u.BlobBuilder || u.WebKitBlobBuilder;
        return a
          ? ((a = new a()), a.append(c), a.getBlob(b))
          : new Blob([c], b ? { type: b } : {});
      },
      canvasToDataUrl: function(c, b, a) {
        return c.toDataURL(b, a / 100);
      },
      parseMeta: function(c, b) {
        b(!1, {});
      },
      updateImageHead: function(c) {
        return c;
      }
    };
  });
  m("runtime/html5/imagemeta", ["runtime/html5/util"], function(g) {
    var h;
    h = {
      parsers: { 65505: [] },
      maxMetaDataSize: 262144,
      parse: function(k, c) {
        var b = this,
          a = new FileReader();
        a.onload = function() {
          c(!1, b._parse(this.result));
          a = a.onload = a.onerror = null;
        };
        a.onerror = function(b) {
          c(b.message);
          a = a.onload = a.onerror = null;
        };
        k = k.slice(0, b.maxMetaDataSize);
        a.readAsArrayBuffer(k.getSource());
      },
      _parse: function(k, c) {
        if (!(6 > k.byteLength)) {
          var b = new DataView(k),
            a = 2,
            f = b.byteLength - 4,
            e = a,
            d = {},
            g,
            r;
          if (65496 === b.getUint16(0)) {
            for (; a < f; )
              if (
                ((g = b.getUint16(a)),
                (65504 <= g && 65519 >= g) || 65534 === g)
              ) {
                r = b.getUint16(a + 2) + 2;
                if (a + r > b.byteLength) break;
                e = h.parsers[g];
                if (!c && e)
                  for (g = 0; g < e.length; g += 1) e[g].call(h, b, a, r, d);
                e = a += r;
              } else break;
            6 < e &&
              (d.imageHead = k.slice
                ? k.slice(2, e)
                : new Uint8Array(k).subarray(2, e));
          }
          return d;
        }
      },
      updateImageHead: function(k, c) {
        var b = this._parse(k, !0),
          a;
        a = 2;
        b.imageHead && (a = 2 + b.imageHead.byteLength);
        a = k.slice ? k.slice(a) : new Uint8Array(k).subarray(a);
        b = new Uint8Array(c.byteLength + 2 + a.byteLength);
        b[0] = 255;
        b[1] = 216;
        b.set(new Uint8Array(c), 2);
        b.set(new Uint8Array(a), c.byteLength + 2);
        return b.buffer;
      }
    };
    g.parseMeta = function() {
      return h.parse.apply(h, arguments);
    };
    g.updateImageHead = function() {
      return h.updateImageHead.apply(h, arguments);
    };
    return h;
  });
  m(
    "runtime/html5/imagemeta/exif",
    ["base", "runtime/html5/imagemeta"],
    function(g, h) {
      var k = {
        ExifMap: function() {
          return this;
        }
      };
      k.ExifMap.prototype.map = { Orientation: 274 };
      k.ExifMap.prototype.get = function(c) {
        return this[c] || this[this.map[c]];
      };
      k.exifTagTypes = {
        1: {
          getValue: function(c, b) {
            return c.getUint8(b);
          },
          size: 1
        },
        2: {
          getValue: function(c, b) {
            return String.fromCharCode(c.getUint8(b));
          },
          size: 1,
          ascii: !0
        },
        3: {
          getValue: function(c, b, a) {
            return c.getUint16(b, a);
          },
          size: 2
        },
        4: {
          getValue: function(c, b, a) {
            return c.getUint32(b, a);
          },
          size: 4
        },
        5: {
          getValue: function(c, b, a) {
            return c.getUint32(b, a) / c.getUint32(b + 4, a);
          },
          size: 8
        },
        9: {
          getValue: function(c, b, a) {
            return c.getInt32(b, a);
          },
          size: 4
        },
        10: {
          getValue: function(c, b, a) {
            return c.getInt32(b, a) / c.getInt32(b + 4, a);
          },
          size: 8
        }
      };
      k.exifTagTypes[7] = k.exifTagTypes[1];
      k.getExifValue = function(c, b, a, f, e, d) {
        f = k.exifTagTypes[f];
        var h, r;
        if (f)
          if (
            ((h = f.size * e),
            (r = 4 < h ? b + c.getUint32(a + 8, d) : a + 8),
            r + h > c.byteLength)
          )
            g.log("Invalid Exif data: Invalid data offset.");
          else {
            if (1 === e) return f.getValue(c, r, d);
            b = [];
            for (a = 0; a < e; a += 1) b[a] = f.getValue(c, r + a * f.size, d);
            if (f.ascii) {
              c = "";
              for (a = 0; a < b.length; a += 1) {
                e = b[a];
                if ("\x00" === e) break;
                c += e;
              }
              return c;
            }
            return b;
          }
        else g.log("Invalid Exif data: Invalid tag type.");
      };
      k.parseExifTag = function(c, b, a, f, e) {
        var d = c.getUint16(a, f);
        e.exif[d] = k.getExifValue(
          c,
          b,
          a,
          c.getUint16(a + 2, f),
          c.getUint32(a + 4, f),
          f
        );
      };
      k.parseExifTags = function(c, b, a, f, e) {
        var d, k, h;
        if (a + 6 > c.byteLength)
          g.log("Invalid Exif data: Invalid directory offset.");
        else if (
          ((d = c.getUint16(a, f)), (k = a + 2 + 12 * d), k + 4 > c.byteLength)
        )
          g.log("Invalid Exif data: Invalid directory size.");
        else {
          for (h = 0; h < d; h += 1)
            this.parseExifTag(c, b, a + 2 + 12 * h, f, e);
          return c.getUint32(k, f);
        }
      };
      k.parseExifData = function(c, b, a, f) {
        a = b + 10;
        var e;
        if (1165519206 === c.getUint32(b + 4))
          if (a + 8 > c.byteLength)
            g.log("Invalid Exif data: Invalid segment size.");
          else if (0 !== c.getUint16(b + 8))
            g.log("Invalid Exif data: Missing byte alignment offset.");
          else {
            switch (c.getUint16(a)) {
              case 18761:
                b = !0;
                break;
              case 19789:
                b = !1;
                break;
              default:
                g.log("Invalid Exif data: Invalid byte alignment marker.");
                return;
            }
            42 !== c.getUint16(a + 2, b)
              ? g.log("Invalid Exif data: Missing TIFF marker.")
              : ((e = c.getUint32(a + 4, b)),
                (f.exif = new k.ExifMap()),
                k.parseExifTags(c, a, a + e, b, f));
          }
      };
      h.parsers[65505].push(k.parseExifData);
      return k;
    }
  );
  m("runtime/html5/jpegencoder", [], function(g, h, k) {
    function c(b) {
      function a(a, b) {
        for (var c = 0, e = 0, f = [], d = 1; 16 >= d; d++) {
          for (var k = 1; k <= a[d]; k++)
            (f[b[e]] = []), (f[b[e]][0] = c), (f[b[e]][1] = d), e++, c++;
          c *= 2;
        }
        return f;
      }
      function c(a) {
        var b = a[0];
        for (a = a[1] - 1; 0 <= a; )
          b & (1 << a) && (L |= 1 << F),
            a--,
            F--,
            0 > F && (255 == L ? (e(255), e(0)) : e(L), (F = 7), (L = 0));
      }
      function e(a) {
        N.push(P[a]);
      }
      function d(a) {
        e((a >> 8) & 255);
        e(a & 255);
      }
      function k(a, b, e, d, g) {
        var y = g[0],
          x = g[240],
          h,
          w,
          t,
          l,
          n,
          q,
          r,
          p,
          m,
          v = 0;
        for (h = 0; 8 > h; ++h) {
          w = a[v];
          t = a[v + 1];
          l = a[v + 2];
          n = a[v + 3];
          q = a[v + 4];
          r = a[v + 5];
          p = a[v + 6];
          m = a[v + 7];
          var z = w + m;
          w -= m;
          m = t + p;
          t -= p;
          p = l + r;
          l -= r;
          r = n + q;
          n -= q;
          q = z + r;
          z -= r;
          r = m + p;
          m -= p;
          a[v] = q + r;
          a[v + 4] = q - r;
          q = 0.707106781 * (m + z);
          a[v + 2] = z + q;
          a[v + 6] = z - q;
          q = n + l;
          r = l + t;
          m = t + w;
          l = 0.382683433 * (q - m);
          n = 0.5411961 * q + l;
          q = 1.306562965 * m + l;
          r *= 0.707106781;
          l = w + r;
          w -= r;
          a[v + 5] = w + n;
          a[v + 3] = w - n;
          a[v + 1] = l + q;
          a[v + 7] = l - q;
          v += 8;
        }
        for (h = v = 0; 8 > h; ++h)
          (w = a[v]),
            (t = a[v + 8]),
            (l = a[v + 16]),
            (n = a[v + 24]),
            (q = a[v + 32]),
            (r = a[v + 40]),
            (p = a[v + 48]),
            (m = a[v + 56]),
            (z = w + m),
            (w -= m),
            (m = t + p),
            (t -= p),
            (p = l + r),
            (l -= r),
            (r = n + q),
            (n -= q),
            (q = z + r),
            (z -= r),
            (r = m + p),
            (m -= p),
            (a[v] = q + r),
            (a[v + 32] = q - r),
            (q = 0.707106781 * (m + z)),
            (a[v + 16] = z + q),
            (a[v + 48] = z - q),
            (q = n + l),
            (r = l + t),
            (m = t + w),
            (l = 0.382683433 * (q - m)),
            (n = 0.5411961 * q + l),
            (q = 1.306562965 * m + l),
            (r *= 0.707106781),
            (l = w + r),
            (w -= r),
            (a[v + 40] = w + n),
            (a[v + 24] = w - n),
            (a[v + 8] = l + q),
            (a[v + 56] = l - q),
            v++;
        for (h = 0; 64 > h; ++h)
          (v = a[h] * b[h]), (G[h] = 0 < v ? (v + 0.5) | 0 : (v - 0.5) | 0);
        a = G;
        for (b = 0; 64 > b; ++b) E[K[b]] = a[b];
        a = E[0] - e;
        e = E[0];
        0 == a ? c(d[0]) : ((h = 32767 + a), c(d[C[h]]), c(u[h]));
        for (d = 63; 0 < d && 0 == E[d]; d--);
        if (0 == d) return c(y), e;
        for (a = 1; a <= d; ) {
          for (b = a; 0 == E[a] && a <= d; ++a);
          b = a - b;
          if (16 <= b) {
            h = b >> 4;
            for (v = 1; v <= h; ++v) c(x);
            b &= 15;
          }
          h = 32767 + E[a];
          c(g[(b << 4) + C[h]]);
          c(u[h]);
          a++;
        }
        63 != d && c(y);
        return e;
      }
      function g(a) {
        0 >= a && (a = 1);
        100 < a && (a = 100);
        if (Q != a) {
          for (
            var b = 0,
              b = 50 > a ? Math.floor(5e3 / a) : Math.floor(200 - 2 * a),
              c = [
                16,
                11,
                10,
                16,
                24,
                40,
                51,
                61,
                12,
                12,
                14,
                19,
                26,
                58,
                60,
                55,
                14,
                13,
                16,
                24,
                40,
                57,
                69,
                56,
                14,
                17,
                22,
                29,
                51,
                87,
                80,
                62,
                18,
                22,
                37,
                56,
                68,
                109,
                103,
                77,
                24,
                35,
                55,
                64,
                81,
                104,
                113,
                92,
                49,
                64,
                78,
                87,
                103,
                121,
                120,
                101,
                72,
                92,
                95,
                98,
                112,
                100,
                103,
                99
              ],
              e = 0;
            64 > e;
            e++
          ) {
            var f = h((c[e] * b + 50) / 100);
            1 > f ? (f = 1) : 255 < f && (f = 255);
            p[K[e]] = f;
          }
          c = [
            17,
            18,
            24,
            47,
            99,
            99,
            99,
            99,
            18,
            21,
            26,
            66,
            99,
            99,
            99,
            99,
            24,
            26,
            56,
            99,
            99,
            99,
            99,
            99,
            47,
            66,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99,
            99
          ];
          for (e = 0; 64 > e; e++)
            (f = h((c[e] * b + 50) / 100)),
              1 > f ? (f = 1) : 255 < f && (f = 255),
              (t[K[e]] = f);
          b = [
            1,
            1.387039845,
            1.306562965,
            1.175875602,
            1,
            0.785694958,
            0.5411961,
            0.275899379
          ];
          for (e = c = 0; 8 > e; e++)
            for (f = 0; 8 > f; f++)
              (x[c] = 1 / (p[K[c]] * b[e] * b[f] * 8)),
                (y[c] = 1 / (t[K[c]] * b[e] * b[f] * 8)),
                c++;
          Q = a;
        }
      }
      var h = Math.floor,
        p = Array(64),
        t = Array(64),
        x = Array(64),
        y = Array(64),
        w,
        l,
        n,
        m,
        u = Array(65535),
        C = Array(65535),
        G = Array(64),
        E = Array(64),
        N = [],
        L = 0,
        F = 7,
        D = Array(64),
        R = Array(64),
        S = Array(64),
        P = Array(256),
        A = Array(2048),
        Q,
        K = [
          0,
          1,
          5,
          6,
          14,
          15,
          27,
          28,
          2,
          4,
          7,
          13,
          16,
          26,
          29,
          42,
          3,
          8,
          12,
          17,
          25,
          30,
          41,
          43,
          9,
          11,
          18,
          24,
          31,
          40,
          44,
          53,
          10,
          19,
          23,
          32,
          39,
          45,
          52,
          54,
          20,
          22,
          33,
          38,
          46,
          51,
          55,
          60,
          21,
          34,
          37,
          47,
          50,
          56,
          59,
          61,
          35,
          36,
          48,
          49,
          57,
          58,
          62,
          63
        ],
        T = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
        U = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
        V = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125],
        W = [
          1,
          2,
          3,
          0,
          4,
          17,
          5,
          18,
          33,
          49,
          65,
          6,
          19,
          81,
          97,
          7,
          34,
          113,
          20,
          50,
          129,
          145,
          161,
          8,
          35,
          66,
          177,
          193,
          21,
          82,
          209,
          240,
          36,
          51,
          98,
          114,
          130,
          9,
          10,
          22,
          23,
          24,
          25,
          26,
          37,
          38,
          39,
          40,
          41,
          42,
          52,
          53,
          54,
          55,
          56,
          57,
          58,
          67,
          68,
          69,
          70,
          71,
          72,
          73,
          74,
          83,
          84,
          85,
          86,
          87,
          88,
          89,
          90,
          99,
          100,
          101,
          102,
          103,
          104,
          105,
          106,
          115,
          116,
          117,
          118,
          119,
          120,
          121,
          122,
          131,
          132,
          133,
          134,
          135,
          136,
          137,
          138,
          146,
          147,
          148,
          149,
          150,
          151,
          152,
          153,
          154,
          162,
          163,
          164,
          165,
          166,
          167,
          168,
          169,
          170,
          178,
          179,
          180,
          181,
          182,
          183,
          184,
          185,
          186,
          194,
          195,
          196,
          197,
          198,
          199,
          200,
          201,
          202,
          210,
          211,
          212,
          213,
          214,
          215,
          216,
          217,
          218,
          225,
          226,
          227,
          228,
          229,
          230,
          231,
          232,
          233,
          234,
          241,
          242,
          243,
          244,
          245,
          246,
          247,
          248,
          249,
          250
        ],
        X = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
        Y = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
        Z = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119],
        aa = [
          0,
          1,
          2,
          3,
          17,
          4,
          5,
          33,
          49,
          6,
          18,
          65,
          81,
          7,
          97,
          113,
          19,
          34,
          50,
          129,
          8,
          20,
          66,
          145,
          161,
          177,
          193,
          9,
          35,
          51,
          82,
          240,
          21,
          98,
          114,
          209,
          10,
          22,
          36,
          52,
          225,
          37,
          241,
          23,
          24,
          25,
          26,
          38,
          39,
          40,
          41,
          42,
          53,
          54,
          55,
          56,
          57,
          58,
          67,
          68,
          69,
          70,
          71,
          72,
          73,
          74,
          83,
          84,
          85,
          86,
          87,
          88,
          89,
          90,
          99,
          100,
          101,
          102,
          103,
          104,
          105,
          106,
          115,
          116,
          117,
          118,
          119,
          120,
          121,
          122,
          130,
          131,
          132,
          133,
          134,
          135,
          136,
          137,
          138,
          146,
          147,
          148,
          149,
          150,
          151,
          152,
          153,
          154,
          162,
          163,
          164,
          165,
          166,
          167,
          168,
          169,
          170,
          178,
          179,
          180,
          181,
          182,
          183,
          184,
          185,
          186,
          194,
          195,
          196,
          197,
          198,
          199,
          200,
          201,
          202,
          210,
          211,
          212,
          213,
          214,
          215,
          216,
          217,
          218,
          226,
          227,
          228,
          229,
          230,
          231,
          232,
          233,
          234,
          242,
          243,
          244,
          245,
          246,
          247,
          248,
          249,
          250
        ];
      this.encode = function(a, b) {
        b && g(b);
        N = [];
        L = 0;
        F = 7;
        d(65496);
        d(65504);
        d(16);
        e(74);
        e(70);
        e(73);
        e(70);
        e(0);
        e(1);
        e(1);
        e(0);
        d(1);
        d(1);
        e(0);
        e(0);
        d(65499);
        d(132);
        e(0);
        for (var h = 0; 64 > h; h++) e(p[h]);
        e(1);
        for (h = 0; 64 > h; h++) e(t[h]);
        var h = a.width,
          z = a.height;
        d(65472);
        d(17);
        e(8);
        d(z);
        d(h);
        e(3);
        e(1);
        e(17);
        e(0);
        e(2);
        e(17);
        e(1);
        e(3);
        e(17);
        e(1);
        d(65476);
        d(418);
        e(0);
        for (h = 0; 16 > h; h++) e(T[h + 1]);
        for (h = 0; 11 >= h; h++) e(U[h]);
        e(16);
        for (h = 0; 16 > h; h++) e(V[h + 1]);
        for (h = 0; 161 >= h; h++) e(W[h]);
        e(1);
        for (h = 0; 16 > h; h++) e(X[h + 1]);
        for (h = 0; 11 >= h; h++) e(Y[h]);
        e(17);
        for (h = 0; 16 > h; h++) e(Z[h + 1]);
        for (h = 0; 161 >= h; h++) e(aa[h]);
        d(65498);
        d(12);
        e(3);
        e(1);
        e(0);
        e(2);
        e(17);
        e(3);
        e(17);
        e(0);
        e(63);
        e(0);
        var u = (z = h = 0);
        L = 0;
        F = 7;
        this.encode.displayName = "_encode_";
        for (
          var O = a.data,
            E = a.height,
            G = 4 * a.width,
            C,
            M = 0,
            H,
            I,
            B,
            K,
            J;
          M < E;

        ) {
          for (C = 0; C < G; ) {
            K = G * M + C;
            for (J = 0; 64 > J; J++)
              (I = J >> 3),
                (H = 4 * (J & 7)),
                (B = K + I * G + H),
                M + I >= E && (B -= G * (M + 1 + I - E)),
                C + H >= G && (B -= C + H - G + 4),
                (H = O[B++]),
                (I = O[B++]),
                (B = O[B++]),
                (D[J] =
                  ((A[H] + A[(I + 256) >> 0] + A[(B + 512) >> 0]) >> 16) - 128),
                (R[J] =
                  ((A[(H + 768) >> 0] +
                    A[(I + 1024) >> 0] +
                    A[(B + 1280) >> 0]) >>
                    16) -
                  128),
                (S[J] =
                  ((A[(H + 1280) >> 0] +
                    A[(I + 1536) >> 0] +
                    A[(B + 1792) >> 0]) >>
                    16) -
                  128);
            h = k(D, x, h, w, n);
            z = k(R, y, z, l, m);
            u = k(S, y, u, l, m);
            C += 32;
          }
          M += 8;
        }
        0 <= F && ((h = []), (h[1] = F + 1), (h[0] = (1 << (F + 1)) - 1), c(h));
        d(65497);
        h = "data:image/jpeg;base64," + btoa(N.join(""));
        N = [];
        return h;
      };
      b || (b = 50);
      (function() {
        for (var a = String.fromCharCode, b = 0; 256 > b; b++) P[b] = a(b);
      })();
      w = a(T, U);
      l = a(X, Y);
      n = a(V, W);
      m = a(Z, aa);
      (function() {
        for (var a = 1, b = 2, c = 1; 15 >= c; c++) {
          for (var e = a; e < b; e++)
            (C[32767 + e] = c),
              (u[32767 + e] = []),
              (u[32767 + e][1] = c),
              (u[32767 + e][0] = e);
          for (e = -(b - 1); e <= -a; e++)
            (C[32767 + e] = c),
              (u[32767 + e] = []),
              (u[32767 + e][1] = c),
              (u[32767 + e][0] = b - 1 + e);
          a <<= 1;
          b <<= 1;
        }
      })();
      (function() {
        for (var a = 0; 256 > a; a++)
          (A[a] = 19595 * a),
            (A[(a + 256) >> 0] = 38470 * a),
            (A[(a + 512) >> 0] = 7471 * a + 32768),
            (A[(a + 768) >> 0] = -11059 * a),
            (A[(a + 1024) >> 0] = -21709 * a),
            (A[(a + 1280) >> 0] = 32768 * a + 8421375),
            (A[(a + 1536) >> 0] = -27439 * a),
            (A[(a + 1792) >> 0] = -5329 * a);
      })();
      g(b);
    }
    c.encode = function(b, a) {
      return new c(a).encode(b);
    };
    return c;
  });
  m(
    "runtime/html5/androidpatch",
    ["runtime/html5/util", "runtime/html5/jpegencoder", "base"],
    function(g, h, k) {
      var c = g.canvasToDataUrl,
        b;
      g.canvasToDataUrl = function(a, f, e) {
        var d, g, r;
        if (!k.os.android) return c.apply(null, arguments);
        "image/jpeg" === f &&
          "undefined" === typeof b &&
          ((d = c.apply(null, arguments)),
          (d = d.split(",")),
          (d = ~d[0].indexOf("base64") ? atob(d[1]) : decodeURIComponent(d[1])),
          (d = d.substring(0, 2)),
          (b = 255 === d.charCodeAt(0) && 216 === d.charCodeAt(1)));
        return "image/jpeg" !== f || b
          ? c.apply(null, arguments)
          : ((g = a.width),
            (r = a.height),
            (d = a.getContext("2d")),
            h.encode(d.getImageData(0, 0, g, r), e));
      };
    }
  );
  m(
    "runtime/html5/image",
    ["base", "runtime/html5/runtime", "runtime/html5/util"],
    function(g, h, k) {
      return h.register("Image", {
        modified: !1,
        init: function() {
          var c = this,
            b = new Image();
          b.onload = function() {
            c._info = { type: c.type, width: this.width, height: this.height };
            debugger;
            c._metas || "image/jpeg" !== c.type
              ? c.owner.trigger("load")
              : k.parseMeta(c._blob, function(a, b) {
                  c._metas = b;
                  c.owner.trigger("load");
                });
          };
          b.onerror = function() {
            c.owner.trigger("error");
          };
          c._img = b;
        },
        loadFromBlob: function(c) {
          var b = this._img;
          this._blob = c;
          this.type = c.type;
          b.src = k.createObjectURL(c.getSource());
          this.owner.once("load", function() {
            k.revokeObjectURL(b.src);
          });
        },
        resize: function(c, b) {
          var a =
            this._canvas || (this._canvas = document.createElement("canvas"));
          this._resize(this._img, a, c, b);
          this._blob = null;
          this.modified = !0;
          this.owner.trigger("complete", "resize");
        },
        crop: function(c, b, a, f, e) {
          var d =
              this._canvas || (this._canvas = document.createElement("canvas")),
            k = this.options,
            h = this._img,
            g = h.naturalWidth,
            p = h.naturalHeight,
            t = this.getOrientation();
          e = e || 1;
          d.width = a;
          d.height = f;
          k.preserveHeaders || this._rotate2Orientaion(d, t);
          this._renderImageToCanvas(d, h, -c, -b, g * e, p * e);
          this._blob = null;
          this.modified = !0;
          this.owner.trigger("complete", "crop");
        },
        getAsBlob: function(c) {
          var b = this._blob,
            a = this.options;
          c = c || this.type;
          if (this.modified || this.type !== c) {
            b = this._canvas;
            if ("image/jpeg" === c) {
              if (
                ((b = k.canvasToDataUrl(b, c, a.quality)),
                a.preserveHeaders && this._metas && this._metas.imageHead)
              )
                return (
                  (b = k.dataURL2ArrayBuffer(b)),
                  (b = k.updateImageHead(b, this._metas.imageHead)),
                  (b = k.arrayBufferToBlob(b, c))
                );
            } else b = k.canvasToDataUrl(b, c);
            b = k.dataURL2Blob(b);
          }
          return b;
        },
        getAsDataUrl: function(c) {
          var b = this.options;
          c = c || this.type;
          return "image/jpeg" === c
            ? k.canvasToDataUrl(this._canvas, c, b.quality)
            : this._canvas.toDataURL(c);
        },
        getOrientation: function() {
          return (
            (this._metas &&
              this._metas.exif &&
              this._metas.exif.get("Orientation")) ||
            1
          );
        },
        info: function(c) {
          return c ? ((this._info = c), this) : this._info;
        },
        meta: function(c) {
          return c ? ((this._metas = c), this) : this._metas;
        },
        destroy: function() {
          var c = this._canvas;
          this._img.onload = null;
          c &&
            (c.getContext("2d").clearRect(0, 0, c.width, c.height),
            (c.width = c.height = 0),
            (this._canvas = null));
          this._img.src =
            "%3D";
          this._img = this._blob = null;
        },
        _resize: function(c, b, a, f) {
          var e = this.options,
            d = c.width,
            h = c.height,
            k = this.getOrientation(),
            g;
          ~[5, 6, 7, 8].indexOf(k) && ((a ^= f), (f ^= a), (a ^= f));
          g = Math[e.crop ? "max" : "min"](a / d, f / h);
          e.allowMagnify || (g = Math.min(1, g));
          d *= g;
          h *= g;
          e.crop
            ? ((b.width = a), (b.height = f))
            : ((b.width = d), (b.height = h));
          a = (b.width - d) / 2;
          f = (b.height - h) / 2;
          e.preserveHeaders || this._rotate2Orientaion(b, k);
          this._renderImageToCanvas(b, c, a, f, d, h);
        },
        _rotate2Orientaion: function(c, b) {
          var a = c.width,
            f = c.height,
            e = c.getContext("2d");
          switch (b) {
            case 5:
            case 6:
            case 7:
            case 8:
              (c.width = f), (c.height = a);
          }
          switch (b) {
            case 2:
              e.translate(a, 0);
              e.scale(-1, 1);
              break;
            case 3:
              e.translate(a, f);
              e.rotate(Math.PI);
              break;
            case 4:
              e.translate(0, f);
              e.scale(1, -1);
              break;
            case 5:
              e.rotate(0.5 * Math.PI);
              e.scale(1, -1);
              break;
            case 6:
              e.rotate(0.5 * Math.PI);
              e.translate(0, -f);
              break;
            case 7:
              e.rotate(0.5 * Math.PI);
              e.translate(a, -f);
              e.scale(-1, 1);
              break;
            case 8:
              e.rotate(-0.5 * Math.PI), e.translate(-a, 0);
          }
        },
        _renderImageToCanvas: (function() {
          function c(b, a, c) {
            var e = document.createElement("canvas"),
              d = e.getContext("2d");
            a = 0;
            var h = c,
              k = c;
            e.width = 1;
            e.height = c;
            d.drawImage(b, 0, 0);
            for (b = d.getImageData(0, 0, 1, c).data; k > a; )
              (e = b[4 * (k - 1) + 3]),
                0 === e ? (h = k) : (a = k),
                (k = (h + a) >> 1);
            c = k / c;
            return 0 === c ? 1 : c;
          }
          return g.os.ios
            ? 7 <= g.os.ios
              ? function(b, a, f, e, d, h) {
                  var k = a.naturalWidth,
                    g = a.naturalHeight,
                    p = c(a, k, g);
                  return b
                    .getContext("2d")
                    .drawImage(a, 0, 0, k * p, g * p, f, e, d, h);
                }
              : function(b, a, f, e, d, h) {
                  var k = a.naturalWidth,
                    g = a.naturalHeight;
                  b = b.getContext("2d");
                  var p;
                  var t = a.naturalWidth,
                    x;
                  1048576 < t * a.naturalHeight
                    ? ((x = document.createElement("canvas")),
                      (x.width = x.height = 1),
                      (x = x.getContext("2d")),
                      x.drawImage(a, -t + 1, 0),
                      (p = 0 === x.getImageData(0, 0, 1, 1).data[3]))
                    : (p = !1);
                  var y = "image/jpeg" === this.type;
                  x = t = 0;
                  var w, l;
                  p && ((k /= 2), (g /= 2));
                  b.save();
                  p = document.createElement("canvas");
                  p.width = p.height = 1024;
                  w = p.getContext("2d");
                  y = y ? c(a, k, g) : 1;
                  d = Math.ceil((1024 * d) / k);
                  for (h = Math.ceil((1024 * h) / g / y); t < g; ) {
                    for (l = y = 0; y < k; )
                      w.clearRect(0, 0, 1024, 1024),
                        w.drawImage(a, -y, -t),
                        b.drawImage(p, 0, 0, 1024, 1024, f + l, e + x, d, h),
                        (y += 1024),
                        (l += d);
                    t += 1024;
                    x += h;
                  }
                  b.restore();
                }
            : function(b) {
                var a = g.slice(arguments, 1),
                  c = b.getContext("2d");
                c.drawImage.apply(c, a);
              };
        })()
      });
    }
  );
  m("runtime/html5/transport", ["base", "runtime/html5/runtime"], function(
    g,
    h
  ) {
    var k = g.noop,
      c = g.$;
    return h.register("Transport", {
      init: function() {
        this._status = 0;
        this._response = null;
      },
      send: function() {
        var b = this.owner,
          a = this.options,
          f = this._initAjax(),
          e = b._blob,
          d = a.server,
          k,
          h,
          m;
        a.sendAsBinary
          ? ((d += (/\?/.test(d) ? "&" : "?") + c.param(b._formData)),
            (h = e.getSource()))
          : ((k = new FormData()),
            c.each(b._formData, function(a, b) {
              k.append(a, b);
            }),
            k.append(
              a.fileVal,
              e.getSource(),
              a.filename || b._formData.name || ""
            ));
        a.withCredentials && "withCredentials" in f
          ? (f.open(a.method, d, !0), (f.withCredentials = !0))
          : f.open(a.method, d);
        this._setRequestHeader(f, a.headers);
        h
          ? (f.overrideMimeType &&
              f.overrideMimeType("application/octet-stream"),
            g.os.android
              ? ((m = new FileReader()),
                (m.onload = function() {
                  f.send(this.result);
                  m = m.onload = null;
                }),
                m.readAsArrayBuffer(h))
              : f.send(h))
          : f.send(k);
      },
      getResponse: function() {
        return this._response;
      },
      getResponseAsJson: function() {
        return this._parseJson(this._response);
      },
      getStatus: function() {
        return this._status;
      },
      abort: function() {
        var b = this._xhr;
        b &&
          ((b.upload.onprogress = k),
          (b.onreadystatechange = k),
          b.abort(),
          (this._xhr = null));
      },
      destroy: function() {
        this.abort();
      },
      _initAjax: function() {
        var b = this,
          a = new XMLHttpRequest();
        !this.options.withCredentials ||
          "withCredentials" in a ||
          "undefined" === typeof XDomainRequest ||
          (a = new XDomainRequest());
        a.upload.onprogress = function(a) {
          var c = 0;
          a.lengthComputable && (c = a.loaded / a.total);
          return b.trigger("progress", c);
        };
        a.onreadystatechange = function() {
          if (4 === a.readyState)
            return (
              (a.upload.onprogress = k),
              (a.onreadystatechange = k),
              (b._xhr = null),
              (b._status = a.status),
              200 <= a.status && 300 > a.status
                ? ((b._response = a.responseText), b.trigger("load"))
                : 500 <= a.status && 600 > a.status
                ? ((b._response = a.responseText), b.trigger("error", "server"))
                : b.trigger("error", b._status ? "http" : "abort")
            );
        };
        return (b._xhr = a);
      },
      _setRequestHeader: function(b, a) {
        c.each(a, function(a, c) {
          b.setRequestHeader(a, c);
        });
      },
      _parseJson: function(b) {
        var a;
        try {
          a = JSON.parse(b);
        } catch (c) {
          a = {};
        }
        return a;
      }
    });
  });
  m("runtime/html5/md5", ["runtime/html5/runtime"], function(g) {
    var h = function(a, b) {
        return (a + b) & 4294967295;
      },
      k = function(a, b, c, e, f, d) {
        b = h(h(b, a), h(e, d));
        return h((b << f) | (b >>> (32 - f)), c);
      },
      c = function(a, b, c, e, f, d, h) {
        return k((b & c) | (~b & e), a, b, f, d, h);
      },
      b = function(a, b, c, e, f, d, h) {
        return k((b & e) | (c & ~e), a, b, f, d, h);
      },
      a = function(a, b, c, e, f, d, h) {
        return k(c ^ (b | ~e), a, b, f, d, h);
      },
      f = function(e, f) {
        var d = e[0],
          g = e[1],
          l = e[2],
          n = e[3],
          d = c(d, g, l, n, f[0], 7, -680876936),
          n = c(n, d, g, l, f[1], 12, -389564586),
          l = c(l, n, d, g, f[2], 17, 606105819),
          g = c(g, l, n, d, f[3], 22, -1044525330),
          d = c(d, g, l, n, f[4], 7, -176418897),
          n = c(n, d, g, l, f[5], 12, 1200080426),
          l = c(l, n, d, g, f[6], 17, -1473231341),
          g = c(g, l, n, d, f[7], 22, -45705983),
          d = c(d, g, l, n, f[8], 7, 1770035416),
          n = c(n, d, g, l, f[9], 12, -1958414417),
          l = c(l, n, d, g, f[10], 17, -42063),
          g = c(g, l, n, d, f[11], 22, -1990404162),
          d = c(d, g, l, n, f[12], 7, 1804603682),
          n = c(n, d, g, l, f[13], 12, -40341101),
          l = c(l, n, d, g, f[14], 17, -1502002290),
          g = c(g, l, n, d, f[15], 22, 1236535329),
          d = b(d, g, l, n, f[1], 5, -165796510),
          n = b(n, d, g, l, f[6], 9, -1069501632),
          l = b(l, n, d, g, f[11], 14, 643717713),
          g = b(g, l, n, d, f[0], 20, -373897302),
          d = b(d, g, l, n, f[5], 5, -701558691),
          n = b(n, d, g, l, f[10], 9, 38016083),
          l = b(l, n, d, g, f[15], 14, -660478335),
          g = b(g, l, n, d, f[4], 20, -405537848),
          d = b(d, g, l, n, f[9], 5, 568446438),
          n = b(n, d, g, l, f[14], 9, -1019803690),
          l = b(l, n, d, g, f[3], 14, -187363961),
          g = b(g, l, n, d, f[8], 20, 1163531501),
          d = b(d, g, l, n, f[13], 5, -1444681467),
          n = b(n, d, g, l, f[2], 9, -51403784),
          l = b(l, n, d, g, f[7], 14, 1735328473),
          g = b(g, l, n, d, f[12], 20, -1926607734),
          d = k(g ^ l ^ n, d, g, f[5], 4, -378558),
          n = k(d ^ g ^ l, n, d, f[8], 11, -2022574463),
          l = k(n ^ d ^ g, l, n, f[11], 16, 1839030562),
          g = k(l ^ n ^ d, g, l, f[14], 23, -35309556),
          d = k(g ^ l ^ n, d, g, f[1], 4, -1530992060),
          n = k(d ^ g ^ l, n, d, f[4], 11, 1272893353),
          l = k(n ^ d ^ g, l, n, f[7], 16, -155497632),
          g = k(l ^ n ^ d, g, l, f[10], 23, -1094730640),
          d = k(g ^ l ^ n, d, g, f[13], 4, 681279174),
          n = k(d ^ g ^ l, n, d, f[0], 11, -358537222),
          l = k(n ^ d ^ g, l, n, f[3], 16, -722521979),
          g = k(l ^ n ^ d, g, l, f[6], 23, 76029189),
          d = k(g ^ l ^ n, d, g, f[9], 4, -640364487),
          n = k(d ^ g ^ l, n, d, f[12], 11, -421815835),
          l = k(n ^ d ^ g, l, n, f[15], 16, 530742520),
          g = k(l ^ n ^ d, g, l, f[2], 23, -995338651),
          d = a(d, g, l, n, f[0], 6, -198630844),
          n = a(n, d, g, l, f[7], 10, 1126891415),
          l = a(l, n, d, g, f[14], 15, -1416354905),
          g = a(g, l, n, d, f[5], 21, -57434055),
          d = a(d, g, l, n, f[12], 6, 1700485571),
          n = a(n, d, g, l, f[3], 10, -1894986606),
          l = a(l, n, d, g, f[10], 15, -1051523),
          g = a(g, l, n, d, f[1], 21, -2054922799),
          d = a(d, g, l, n, f[8], 6, 1873313359),
          n = a(n, d, g, l, f[15], 10, -30611744),
          l = a(l, n, d, g, f[6], 15, -1560198380),
          g = a(g, l, n, d, f[13], 21, 1309151649),
          d = a(d, g, l, n, f[4], 6, -145523070),
          n = a(n, d, g, l, f[11], 10, -1120210379),
          l = a(l, n, d, g, f[2], 15, 718787259),
          g = a(g, l, n, d, f[9], 21, -343485551);
        e[0] = h(d, e[0]);
        e[1] = h(g, e[1]);
        e[2] = h(l, e[2]);
        e[3] = h(n, e[3]);
      },
      e = function(a) {
        var b = [],
          c;
        for (c = 0; 64 > c; c += 4)
          b[c >> 2] =
            a.charCodeAt(c) +
            (a.charCodeAt(c + 1) << 8) +
            (a.charCodeAt(c + 2) << 16) +
            (a.charCodeAt(c + 3) << 24);
        return b;
      },
      d = function(a) {
        var b = [],
          c;
        for (c = 0; 64 > c; c += 4)
          b[c >> 2] =
            a[c] + (a[c + 1] << 8) + (a[c + 2] << 16) + (a[c + 3] << 24);
        return b;
      },
      m = function(a) {
        var b = a.length,
          c = [1732584193, -271733879, -1732584194, 271733878],
          d,
          g,
          h;
        for (d = 64; d <= b; d += 64) f(c, e(a.substring(d - 64, d)));
        a = a.substring(d - 64);
        g = a.length;
        h = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
        for (d = 0; d < g; d += 1) h[d >> 2] |= a.charCodeAt(d) << (d % 4 << 3);
        h[d >> 2] |= 128 << (d % 4 << 3);
        if (55 < d) for (f(c, h), d = 0; 16 > d; d += 1) h[d] = 0;
        b = (8 * b).toString(16).match(/(.*?)(.{0,8})$/);
        a = parseInt(b[2], 16);
        b = parseInt(b[1], 16) || 0;
        h[14] = a;
        h[15] = b;
        f(c, h);
        return c;
      },
      r = "0123456789abcdef".split(""),
      u = function(a) {
        var b;
        for (b = 0; b < a.length; b += 1) {
          for (var c = b, d = a[b], e = "", f = void 0, f = 0; 4 > f; f += 1)
            e += r[(d >> (8 * f + 4)) & 15] + r[(d >> (8 * f)) & 15];
          a[c] = e;
        }
        return a.join("");
      },
      p = function() {
        this.reset();
      };
    "5d41402abc4b2a76b9719d911017c592" !== u(m("hello")) &&
      (h = function(a, b) {
        var c = (a & 65535) + (b & 65535);
        return (((a >> 16) + (b >> 16) + (c >> 16)) << 16) | (c & 65535);
      });
    p.prototype.append = function(a) {
      /[\u0080-\uFFFF]/.test(a) && (a = unescape(encodeURIComponent(a)));
      this.appendBinary(a);
      return this;
    };
    p.prototype.appendBinary = function(a) {
      this._buff += a;
      this._length += a.length;
      a = this._buff.length;
      var b;
      for (b = 64; b <= a; b += 64)
        f(this._state, e(this._buff.substring(b - 64, b)));
      this._buff = this._buff.substr(b - 64);
      return this;
    };
    p.prototype.end = function(a) {
      var b = this._buff,
        c = b.length,
        d,
        e = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
      for (d = 0; d < c; d += 1) e[d >> 2] |= b.charCodeAt(d) << (d % 4 << 3);
      this._finish(e, c);
      a = a ? this._state : u(this._state);
      this.reset();
      return a;
    };
    p.prototype._finish = function(a, b) {
      var c = b,
        d;
      a[c >> 2] |= 128 << (c % 4 << 3);
      if (55 < c) for (f(this._state, a), c = 0; 16 > c; c += 1) a[c] = 0;
      d = 8 * this._length;
      d = d.toString(16).match(/(.*?)(.{0,8})$/);
      c = parseInt(d[2], 16);
      d = parseInt(d[1], 16) || 0;
      a[14] = c;
      a[15] = d;
      f(this._state, a);
    };
    p.prototype.reset = function() {
      this._buff = "";
      this._length = 0;
      this._state = [1732584193, -271733879, -1732584194, 271733878];
      return this;
    };
    p.prototype.destroy = function() {
      delete this._state;
      delete this._buff;
      delete this._length;
    };
    p.hash = function(a, b) {
      /[\u0080-\uFFFF]/.test(a) && (a = unescape(encodeURIComponent(a)));
      var c = m(a);
      return b ? c : u(c);
    };
    p.hashBinary = function(a, b) {
      var c = m(a);
      return b ? c : u(c);
    };
    p.ArrayBuffer = function() {
      this.reset();
    };
    p.ArrayBuffer.prototype.append = function(a) {
      var b = this._concatArrayBuffer(this._buff, a),
        c = b.length;
      this._length += a.byteLength;
      for (a = 64; a <= c; a += 64) f(this._state, d(b.subarray(a - 64, a)));
      this._buff = a - 64 < c ? b.subarray(a - 64) : new Uint8Array(0);
      return this;
    };
    p.ArrayBuffer.prototype.end = function(a) {
      var b = this._buff,
        c = b.length,
        d = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        e;
      for (e = 0; e < c; e += 1) d[e >> 2] |= b[e] << (e % 4 << 3);
      this._finish(d, c);
      a = a ? this._state : u(this._state);
      this.reset();
      return a;
    };
    p.ArrayBuffer.prototype._finish = p.prototype._finish;
    p.ArrayBuffer.prototype.reset = function() {
      this._buff = new Uint8Array(0);
      this._length = 0;
      this._state = [1732584193, -271733879, -1732584194, 271733878];
      return this;
    };
    p.ArrayBuffer.prototype.destroy = p.prototype.destroy;
    p.ArrayBuffer.prototype._concatArrayBuffer = function(a, b) {
      var c = a.length,
        d = new Uint8Array(c + b.byteLength);
      d.set(a);
      d.set(new Uint8Array(b), c);
      return d;
    };
    p.ArrayBuffer.hash = function(a, b) {
      var c = new Uint8Array(a),
        e = c.length,
        g = [1732584193, -271733879, -1732584194, 271733878],
        h,
        k,
        m;
      for (h = 64; h <= e; h += 64) f(g, d(c.subarray(h - 64, h)));
      c = h - 64 < e ? c.subarray(h - 64) : new Uint8Array(0);
      k = c.length;
      m = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
      for (h = 0; h < k; h += 1) m[h >> 2] |= c[h] << (h % 4 << 3);
      m[h >> 2] |= 128 << (h % 4 << 3);
      if (55 < h) for (f(g, m), h = 0; 16 > h; h += 1) m[h] = 0;
      e = (8 * e).toString(16).match(/(.*?)(.{0,8})$/);
      c = parseInt(e[2], 16);
      e = parseInt(e[1], 16) || 0;
      m[14] = c;
      m[15] = e;
      f(g, m);
      return b ? g : u(g);
    };
    return g.register("Md5", {
      init: function() {},
      loadFromBlob: function(a) {
        var b = a.getSource(),
          c = Math.ceil(b.size / 2097152),
          d = 0,
          e = this.owner,
          f = new p.ArrayBuffer(),
          g = this,
          h = b.mozSlice || b.webkitSlice || b.slice,
          k,
          m;
        m = new FileReader();
        k = function() {
          var p, q;
          p = 2097152 * d;
          q = Math.min(p + 2097152, b.size);
          m.onload = function(b) {
            f.append(b.target.result);
            e.trigger("progress", { total: a.size, loaded: q });
          };
          m.onloadend = function() {
            m.onloadend = m.onload = null;
            ++d < c
              ? setTimeout(k, 1)
              : setTimeout(function() {
                  e.trigger("load");
                  g.result = f.end();
                  k = a = b = f = null;
                  e.trigger("complete");
                }, 50);
          };
          m.readAsArrayBuffer(h.call(b, p, q));
        };
        k();
      },
      getResult: function() {
        return this.result;
      }
    });
  });
  m(
    "runtime/flash/runtime",
    ["base", "runtime/runtime", "runtime/compbase"],
    function(g, h, k) {
      function c() {
        function b(a, c) {
          var e = a.type || a,
            f,
            e = e.split("::");
          f = e[0];
          e = e[1];
          "Ready" === e && f === m.uid
            ? m.trigger("ready")
            : d[f] && d[f].trigger(e.toLowerCase(), a, c);
        }
        var c = {},
          d = {},
          k = this.destroy,
          m = this,
          z = g.guid("webuploader_");
        h.apply(m, arguments);
        m.type = "flash";
        m.exec = function(b, f) {
          var h = this.uid,
            k = g.slice(arguments, 2);
          d[h] = this;
          return a[b] && (c[h] || (c[h] = new a[b](this, m)), (h = c[h]), h[f])
            ? h[f].apply(h, k)
            : m.flashExec.apply(this, arguments);
        };
        u[z] = function() {
          var a = arguments;
          setTimeout(function() {
            b.apply(null, a);
          }, 1);
        };
        this.jsreciver = z;
        this.destroy = function() {
          return k && k.apply(this, arguments);
        };
        this.flashExec = function(a, b) {
          var c = m.getFlash(),
            d = g.slice(arguments, 2);
          return c.exec(this.uid, a, b, d);
        };
      }
      var b = g.$,
        a = {};
      g.inherits(h, {
        constructor: c,
        init: function() {
          var a = this.getContainer(),
            b = this.options,
            c;
          a.css({
            position: "absolute",
            top: "-8px",
            left: "-8px",
            width: "9px",
            height: "9px",
            overflow: "hidden"
          });
          c =
            '<object id="' +
            this.uid +
            '" type="application/x-shockwave-flash" data="' +
            b.swf +
            '" ';
          g.browser.ie &&
            (c += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ');
          c +=
            'width="100%" height="100%" style="outline:0"><param name="movie" value="' +
            b.swf +
            '" /><param name="flashvars" value="uid=' +
            this.uid +
            "&jsreciver=" +
            this.jsreciver +
            '" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /></object>';
          a.html(c);
        },
        getFlash: function() {
          return this._flash
            ? this._flash
            : (this._flash = b("#" + this.uid).get(0));
        }
      });
      c.register = function(c, e) {
        return (e = a[c] = g.inherits(
          k,
          b.extend(
            {
              flashExec: function() {
                var a = this.owner;
                return this.getRuntime().flashExec.apply(a, arguments);
              }
            },
            e
          )
        ));
      };
      11.4 <=
        (function() {
          var a;
          try {
            (a = navigator.plugins["Shockwave Flash"]), (a = a.description);
          } catch (b) {
            try {
              a = new ActiveXObject(
                "ShockwaveFlash.ShockwaveFlash"
              ).GetVariable("$version");
            } catch (c) {
              a = "0.0";
            }
          }
          a = a.match(/\d+/g);
          return parseFloat(a[0] + "." + a[1], 10);
        })() && h.addRuntime("flash", c);
      return c;
    }
  );
  m("runtime/flash/filepicker", ["base", "runtime/flash/runtime"], function(
    g,
    h
  ) {
    var k = g.$;
    return h.register("FilePicker", {
      init: function(c) {
        c = k.extend({}, c);
        var b, a;
        b = c.accept && c.accept.length;
        for (a = 0; a < b; a++)
          c.accept[a].title || (c.accept[a].title = "Files");
        delete c.button;
        delete c.id;
        delete c.container;
        this.flashExec("FilePicker", "init", c);
      },
      destroy: function() {
        this.flashExec("FilePicker", "destroy");
      }
    });
  });
  m("runtime/flash/image", ["runtime/flash/runtime"], function(g) {
    return g.register("Image", {
      loadFromBlob: function(g) {
        var k = this.owner;
        k.info() && this.flashExec("Image", "info", k.info());
        k.meta() && this.flashExec("Image", "meta", k.meta());
        this.flashExec("Image", "loadFromBlob", g.uid);
      }
    });
  });
  m(
    "runtime/flash/transport",
    ["base", "runtime/flash/runtime", "runtime/client"],
    function(g, h, k) {
      var c = g.$;
      return h.register("Transport", {
        init: function() {
          this._status = 0;
          this._responseJson = this._response = null;
        },
        send: function() {
          var b = this.owner,
            a = this.options,
            f = this._initAjax(),
            e = b._blob,
            d = a.server,
            g;
          f.connectRuntime(e.ruid);
          a.sendAsBinary
            ? ((d += (/\?/.test(d) ? "&" : "?") + c.param(b._formData)),
              (g = e.uid))
            : (c.each(b._formData, function(a, b) {
                f.exec("append", a, b);
              }),
              f.exec(
                "appendBlob",
                a.fileVal,
                e.uid,
                a.filename || b._formData.name || ""
              ));
          this._setRequestHeader(f, a.headers);
          f.exec(
            "send",
            {
              method: a.method,
              url: d,
              forceURLStream: a.forceURLStream,
              mimeType: "application/octet-stream"
            },
            g
          );
        },
        getStatus: function() {
          return this._status;
        },
        getResponse: function() {
          return this._response || "";
        },
        getResponseAsJson: function() {
          return this._responseJson;
        },
        abort: function() {
          var b = this._xhr;
          b && (b.exec("abort"), b.destroy(), (this._xhr = null));
        },
        destroy: function() {
          this.abort();
        },
        _initAjax: function() {
          var b = this,
            a = new k("XMLHttpRequest");
          a.on("uploadprogress progress", function(a) {
            a = a.loaded / a.total;
            a = Math.min(1, Math.max(0, a));
            return b.trigger("progress", a);
          });
          a.on("load", function() {
            var c = a.exec("getStatus"),
              e = !1,
              d = "";
            a.off();
            b._xhr = null;
            200 <= c && 300 > c
              ? (e = !0)
              : 500 <= c && 600 > c
              ? ((e = !0), (d = "server"))
              : (d = "http");
            e &&
              ((b._response = a.exec("getResponse")),
              (b._response = decodeURIComponent(b._response)),
              (c =
                (u.JSON && u.JSON.parse) ||
                function(a) {
                  try {
                    return new Function("return " + a).call();
                  } catch (b) {
                    return {};
                  }
                }),
              (b._responseJson = b._response ? c(b._response) : {}));
            a.destroy();
            a = null;
            return d ? b.trigger("error", d) : b.trigger("load");
          });
          a.on("error", function() {
            a.off();
            b._xhr = null;
            b.trigger("error", "http");
          });
          return (b._xhr = a);
        },
        _setRequestHeader: function(b, a) {
          c.each(a, function(a, c) {
            b.exec("setRequestHeader", a, c);
          });
        }
      });
    }
  );
  m("runtime/flash/blob", ["runtime/flash/runtime", "lib/blob"], function(
    g,
    h
  ) {
    return g.register("Blob", {
      slice: function(g, c) {
        var b = this.flashExec("Blob", "slice", g, c);
        return new h(b.uid, b);
      }
    });
  });
  m("runtime/flash/md5", ["runtime/flash/runtime"], function(g) {
    return g.register("Md5", {
      init: function() {},
      loadFromBlob: function(g) {
        return this.flashExec("Md5", "loadFromBlob", g.uid);
      }
    });
  });
  m(
    "preset/all",
    "base widgets/filednd widgets/filepaste widgets/filepicker widgets/image widgets/queue widgets/runtime widgets/upload widgets/validator widgets/md5 runtime/html5/blob runtime/html5/dnd runtime/html5/filepaste runtime/html5/filepicker runtime/html5/imagemeta/exif runtime/html5/androidpatch runtime/html5/image runtime/html5/transport runtime/html5/md5 runtime/flash/filepicker runtime/flash/image runtime/flash/transport runtime/flash/blob runtime/flash/md5".split(
      " "
    ),
    function(g) {
      return g;
    }
  );
  m("widgets/log", ["base", "uploader", "widgets/widget"], function(g, h) {
    function k(b) {
      b = c.extend({}, a, b);
      b = " http://static.tieba.baidu.com/tb/pms/img/st.gif??".replace(
        /^(.*)\?/,
        "$1" + c.param(b)
      );
      new Image().src = b;
    }
    var c = g.$,
      b = (location.hostname || location.host || "protected").toLowerCase(),
      a;
    if (b && /baidu/i.exec(b))
      return (
        (a = {
          dv: 3,
          master: "webuploader",
          online: /test/.exec(b) ? 0 : 1,
          module: "",
          product: b,
          type: 0
        }),
        h.register({
          name: "log",
          init: function() {
            var a = 0,
              b = 0;
            this.owner
              .on("error", function(a) {
                k({
                  type: 2,
                  c_error_code: a
                });
              })
              .on("uploadError", function(a, b) {
                k({ type: 2, c_error_code: "UPLOAD_ERROR", c_reason: "" + b });
              })
              .on("uploadComplete", function(c) {
                a++;
                b += c.size;
              })
              .on("uploadFinished", function() {
                k({ c_count: a, c_size: b });
                a = b = 0;
              });
            k({ c_usage: 1 });
          }
        })
      );
  });
  m("webuploader", ["preset/all", "widgets/log"], function(g) {
    return g;
  });
  return D("webuploader");
});
jQuery.support.cors = !0;
WebUploader.Uploader.register(
  { "before-send-file": "beforeSendFile" },
  {
    beforeSendFile: function(u) {
      var m = WebUploader.Deferred();
      this.options.callback.getToken(u).then(function() {
        m.resolve();
      });
      return m.promise();
    }
  }
);
